• Resolved Younes

    (@vanbom)


    Hi all,
    I tried to retrieve JSON data from a public instagram account using: wp_remote_get() from the public url: $url = https://www.instagram.com/USER/?__a=1 .

    But what I don’t understand is the following:

    If I am connected to my Instagram account from my browser, the https://www.instagram.com/USER/?__a=1 link opens and displays the JSON result.

    On the same browser, I test my Plugin which calls the same URL https://www.instagram.com/USER/?__a=1 but this time with the wp_remote_get() function , the request returns the Login page .

    My questions :
    Do I have to add the Instagram cookie with my request?
    do I need to add specific headers to the function wp_remote_get() ?

    thank you all

Viewing 8 replies - 1 through 8 (of 8 total)
  • Dion

    (@diondesigns)

    You should look at the Instagram API documentation to determine what information must be sent with your request. I’d guess the URL you listed would require cookies since there is nothing in the URL that identifies the user.

    Moderator bcworkz

    (@bcworkz)

    You cannot add cookies from one site to a request from a different site due to security restrictions. There will be some sort of API key you can get from your IG account for use in remote requests. Besides guidance from IG’s docs on their API, there are a few IG plugins in the repository. You could examine their source code for further guidance on how to use their API.

    Thread Starter Younes

    (@vanbom)

    Hi all ,
    Firstly thank you for reply.

    @diondesigns
    The link is as is proposed by Instagram.
    Example : (If I am connect to instagram) no additional params.
    cristiano ronaldo

    @bcworkz
    Yes I saw a few Plugins, but not all of them do what I want.

    Thread Starter Younes

    (@vanbom)

    Hi @alanfuller ,

    Yes I created an APP, but it allows you to read only a user after accepting it.
    The mechanism of instagram basic display api is that: we must send an invitation to the User, and he must give us his permission.

    while me, I want to read the public JSON of a famous person as I indicated in the link in a previouse response .

    As far as I understand, what you have to to is get an authentication token from a user and put it in the header – then you can access the ‘public’ json.

    UPDATE
    The remaining Instagram Legacy API permission (“Basic Permission”) was disabled on June 29, 2020. As of June 29, third-party apps no longer have access to the Legacy API. To avoid disruption of service to your app and business, developers previously using the Legacy API should instead rely on Instagram Basic Display API and Instagram Graph API. Please request approval for required permissions through the App Review process.

    https://www.instagram.com/developer/

    • This reply was modified 4 years, 9 months ago by Alan Fuller.
    Thread Starter Younes

    (@vanbom)

    Hi @alanfuller ,

    I managed to log into the Instagram API and get a token. But I failed to read the JSON file, I don’t know which headers should I add.

    as you can see : token

    Thread Starter Younes

    (@vanbom)

    i think there is no alternative . i close the ticket

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Add additional headers to the wp_remote_get () function.’ is closed to new replies.