Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Example not working #52

Open
datacubeR opened this issue May 24, 2024 · 1 comment
Open

[BUG] Example not working #52

datacubeR opened this issue May 24, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@datacubeR
Copy link

Try HikerAPI SaaS with a free trial https://hikerapi.com/p/KhMxYMSn

Describe the bug
Running the README example simply just don't work.

To Reproduce

from aiograpi import Client

ACCOUNT_USERNAME = "myuser"
ACCOUNT_PASSWORD = "mypassword"

cl = Client()
await cl.login(ACCOUNT_USERNAME, ACCOUNT_PASSWORD)

user_id = await cl.user_id_from_username(ACCOUNT_USERNAME)
medias = await cl.user_medias(user_id, 20)

Traceback

Screenshot from 2024-05-24 16-18-54

Expected behavior
A working Script

Screenshots
Show above...

Desktop (please complete the following information):

  • OS: Pop OS 22.04 LTS
  • Python version 3.10
  • aiograpi version 0.03

Additional context
I'm just getting familiar with the API so a more descriptive error would be very beneficial.

@datacubeR datacubeR added the bug Something isn't working label May 24, 2024
@ajkessel
Copy link

ajkessel commented Jul 8, 2024

You need to do something like this, because async functionality needs to be in an async function:

import asyncio
import aiograpi

async def test():
   ACCOUNT_USERNAME = "myuser"
   ACCOUNT_PASSWORD = "mypassword"
   cl = Client()
   await cl.login(ACCOUNT_USERNAME, ACCOUNT_PASSWORD)
   user_id = await cl.user_id_from_username(ACCOUNT_USERNAME)
   medias = await cl.user_medias(user_id, 20)

async def main():
    await test()

if __name__ ==  '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants