How to get my user id and posts from username on Instagram? - instagram

Due to recent changes on API Instagram, it is not possible to use the endpoint above:
https://www.instagram.com/{username}/?__a=1
I've tried with:
https://i.instagram.com/api/v1/users/web_profile_info/?username=username
However, it is not working correctly to fetch data. Please, could someone help to find a solution?
In advance, thank you very much.

The API endpoint https://i.instagram.com/api/v1/users/web_profile_info/?username=username does in fact work if the client has the X-IG-App-ID request header set. This header value can be obtained by inspecting the request sent via any web browser.

Try with this endpoint if your account is a business account.
https://graph.instagram.com/me/media?fields={id,caption,media_type,media_url,permalink,thumbnail_url,timestamp,username}&access_token=""

Related

Instagram API throwing OAuthAccessTokenException 400 error using client id

I was using the following api to get the latest 3 posts from public accounts to show on the website:
https://api.instagram.com/v1/users/{user-id}/media/recent/?client_id={client-id}&count=3
I had created an app to get the client-id.
However from today, this API has started throwing the following exception:
{
meta: {
error_type: "OAuthAccessTokenException",
code: 400,
error_message: "The access_token provided is invalid."
}
}
Could you please let me know as how to resolve this?
Based on the date, you probably have an older app that got hit by the API migration today, like mine. In short, Instagram decided to make developing for their platform WAY more annoying by requiring all API requests to be authenticated per user, even for data that users shares publicly. So you (like me) will likely be redesigning you app entirely.
To tell, log in to instagram.com/developer and click manage clients; then hit edit next to the set of keys your're trying to use. Up near the top, it will have a section called 'Client Status' -- if yours reads 'Sandbox Mode', fun times ahead! Hopefully you interact with less than 10 users and can stay in sandbox mode, otherwise you'll have to write an essay, film a video, and basically plead to get your permissions back (probably in a few months, when some Instagram intern finally digs his way down to you in the pile of applications). If it reads something eles, you've got another problem altogether and should thank your lucky stars.
In the meantime, I guess I'll get back to sending out dozens of emails to the maintainers of our many, many affiliated Instagram accounts to explain the issue and try to get permissions, so provided we get approved by then, all our social media displays aren't broken during a huge event Saturday. Another option might be to use the OAuth-less json response available here, but that might break terms of service.
I have a solution to this. If you are using the same code I am, which appears likely. I was pulling the last two images using this.
https://api.instagram.com/v1/users/{user-id}/media/recent/?client_id={client-id}&count=3
What I did to get this working is the following.
Login to your Instragram account you are using as the application.
Go to the developer (API) area. https://www.instagram.com/developer/clients/manage/
Manage clients. Make sure your website URL is the same as your valid redirect URL.
Add new Sandbox User. Put in the account of the IG photos you want to reach.
Hit this URL: https://api.instagram.com/oauth/authorize/?client_id=CLIENTID&redirect_uri=REDIRECT_URI&response_type=token where the client ID is the same one you used in your previous app above.
You should get back and access token URL. Copy your access token.
Login as your account that you want the IG photos of. The account you added as a sandbox user and go to developer and approve the Sandbox Invites.
Change your original URL above from https://api.instagram.com/v1/users/{user-id}/media/recent/?client_id={client-id}&count=3 to https://api.instagram.com/v1/users/self/media/recent/?access_token=ACCESS_TOKEN with your access token.
This is the IG API Media endpoint documentation: https://www.instagram.com/developer/endpoints/users/
After that, it all worked for me and while you are in the sandbox, you should be able to pull the last 3 photos or at this point, figure out how to read the JSON to do so.
Has your app been approved after the June 1st Instagram platform changes?
http://developers.instagram.com/post/145262544121/instagram-platform-update-effective-june-1-2016
If you want to retrieve the user media file then try this, It's working for me
https://graph.instagram.com/me/media?fields=id,caption,media_url,media_type&access_token=ACCESS_TOKEN
For some reason the token is no more valid. Request it again.
Possible reasons why a token is no more valid:
changed password
verified the account
logged-in from a different country

Instagram relationship API doesn't work

Hi I'm developing my App by using Instagram API.
When I use relationship API, I got a 404 status Error.
Does not relationship API work??
My request url and parameter is
url : https://api.instagram.com/v1/users/{user-id}/relationship?access_token={myAccess token}
parameter : action // follow
the method of http is post
Is there anybody has experience like this?
I've resolved this problem..
the problem was that I sent wrong user-id in url.
I sent real Instagram user id that is login id.
but the user-id to be used in the url has to be "id" which is returned by other APIs..
If you have problem like this , and If you need futher more information about it.
please comment.
if you want to get information about a user by using the 'real Instagram' nickname you can use:
https://www.instagram.com/NICKNAME/media/

MassPay API Using NVP returns "Security Header Is Not Valid"

I'm trying to follow the instructions at https://developer.paypal.com/docs/classic/mass-pay/integration-guide/MassPayUsingAPI/#id101DEJ0100A for paying a customer. https://www.paypal.com/us/cgi-bin/webscr?cmd=_profile-api-signature# tells me the API username, API password and and signature. I paste those values directly into my program, and POST those parameters (as well as other parameters) to https ://api-3t.paypal.com/nvp and I get this response back:
TIMESTAMP=2015%2d05%2d06T23%3a58%3a01Z&CORRELATIONID=6eef131f4a296&ACK=Failure&VERSION=2%2e3&BUILD=16566018&L_ERRORCODE0=10002&L_SHORTMESSAGE0=Security%20error&L_LONGMESSAGE0=Security%20header%20is%20not%20valid&L_SEVERITYCODE0=Error
Any tips for troubleshooting what might be going on here?
Thanks in advance!
Kevin
That error means the API credentials you're using are not accurate. Double the check the values themselves and make sure you didn't miss any characters or add any extra white space on the ends of the values. Also, make sure you're not sending sandbox credentials to the live PayPal server or vice-verse. That's usually what's happening when people run into this.

instagram api APIAgeGatedError not in the document

when I try to get few people profile use instagram api it shows error message APIAgeGatedError, what does this mean? how to solve it
I can't find documentation about this exception, but I think this problem is related with your IP, I changed IP-adress and problem was solved. Or try to use proxy-server.
The APIAgeGatedError type error is generated because the content from the requested profile is restricted to a minimum age. You can't reach the content for sure with your "general token". Perhaps with an token that has been authorized from the page you are trying to get content from. However Instagram has no provided documentation about this.

Instagram Api: Client is no longer active

Yesterday, I was doing some test with Instagram API. I want to design a web page where I show the lastest photos in our account (Some like social feed). Today, I'm recieving this error: "The client used for authentication is no longer active.".
Somebody knows if I did some wrong working with your API and How can I do to fix this problem.
Best regards.
Thanks.
I'm running into similar issues. Have not been able to successfully pull anything through the API for over 12 hours.
Check out this link for quick API testing:
http://instagram.com/developer/api-console/
Nothing seems to work.

Resources