tuna
tuna

Reputation: 6351

Invalid format for callback url - Instagram API and python requests library

I have the following code to get the images from urls

    params = {'client_id':settings.SOCIAL_AUTH_INSTAGRAM_KEY,
              'client_secret':settings.SOCIAL_AUTH_INSTAGRAM_SECRET,
              'aspect':'media',
              'object_id':instance.hashtag,
              'callback_url':'http://localhost:8000/campaigns/hook'}
    response = requests.post('https://api.instagram.com/v1/subscriptions/', 
                             params=params)

I am using the requests library for sending the post request. But It returns the error message

"Invalid format for \"callback_url\". URL must","start with \"http:\/\/\" or \"https:\/\/\""

I have no idea i am receiving this message. I am sending the request the following url .

https://api.instagram.com/v1/subscriptions/?client_secret=ZZZZZZZ&callback_url=http%3A%2F%2Flocalhost%3A8000%2Fcampaigns%2Fhook&aspect=media&client_id=YYYYYYYYYYY&object_id=asda'

What is the difference btw http%3A%2F%2F and http:\/\/\

Any ideas?

Upvotes: 1

Views: 2364

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1121486

You need to use the data parameter to post data:

response = requests.post('https://api.instagram.com/v1/subscriptions/', 
                         data=params)

The params keyword is for GET parameters only.

You must use a publicly reachable callback URL; http://localhost is not a URL Instagram can reach.

Upvotes: 2

Related Questions