Load instagram images from user's feed via API - api

I am trying to display only the images the client uploaded to instagram on their website. The client's user ID# is 176722013. According to the API this URL will provide just such a feed:
https://api.instagram.com/v1/users/176722013/media/recent
As indicated by the error message, I need to provide either a client_id or an auth_token. Since I don't want to deal with authentication I went ahead and created an "app" in instagram developers to get a client_id # 5b5a6e95469f465f9f70e4ebcf9ee3a6
Yet when I add it to the URL I still get an error that I needed to provide an auth_token. How does that make sense?
https://api.instagram.com/v1/users/176722013/media/recent?client_id=5b5a6e95469f465f9f70e4ebcf9ee3a6
The app is in sandbox mode. When I attempt to submit it for review I must provide the purpose for the app. Upon selecting " I want to display my Instagram posts on my website." as the purpose I get the following message:
You do not need to submit for review for this use case. If you are a
developer and you want to display Instagram content on your website,
then you do not need to submit your app for review. By using a client
in sandbox mode, you can still access the last 20 media of any sandbox
user that grants you permission.
I am truly at a loss for how to proceed. Thanks for any support

As of June 1st, 2016, you need access_token to access API, where did u read: either a client_id or an auth_token ?
authenticate and get access_token and use to get API response.

#snucky you don't need authentication but you do need the users permission - from what I gather, instagram is accessible only by registered users - so you still need the access token - but instead of a server-explicit you need client-implicit.
Make a http request from your client to the api/authorize with the ?client_id=ID AND A redirect_uri=http://yoursite.com/ when the user allows the application, you'll receive an access_token in the url, which you will then use in every subsquent instagram call
read more here

Related

Using Instagram's Graph API, how can I retrieve post data (media url, caption, poster username, etc)

I want to use Instagram's Graph API on my backend server to retrieve data about an Instagram post. On my frontend, users will submit a post URL (like https://www.instagram.com/p/CAvPIm2lszQ/). Then on my backend, I want to take the ID of the post from that URL (so in this case CAvPIm2lszQ) and then I'm hoping that I can pass that ID thru the Instagram Graph API and then retrieve the data that I need (media URL, caption, poster username, etc.).
So would that be possible? I did find documentation on "IG Media" for the Graph API, but under permissions, it says, "A Facebook User access token from a User who created the IG Media object, with the following permissions.."
Unless I'm misunderstanding it, I'm not sure if I'll be able to access posts from various public accounts. I think it's also worth mentioning that my users are not logging into their Instagram accounts to use my service so the only possible "User access token" would be my own.
Any ideas on how I can go about this? I was using the instagram.com/p/{post_id}/?__a=1 endpoint to meet my needs before but it doesn't work on my production server for some reason. So I'm kinda stuck.
Most probably you will not be able to achieve that using Instagram API. First of all the ID you are referring to CAvPIm2lszQ is not the ID that you will use for getting IG Media. The ID is different (it's numeric value like in the sample request from the page you've linked). The full URL that includes CAvPIm2lszQ is in the shortcode field.
At the moment it is not possible to look for the post detail using shortcode. If you want to use that endpoint you need to get the real post ID first, for instance by listing list of posts from given user.
But in order to do so - you need to use Facebook login authorization window to get token from given user. Alternatively you can try to request https://developers.facebook.com/docs/instagram-api/guides/business-discovery but it requires going through App review and having your own company to pass the Business Verification. Keep in mind that this endpoint returns information only about Instagram Professional accounts (Business/Creator account). You will not be able to get information about regular accounts.
And the last thing about ?__a=1 endpoint. This is not the official Instagram API. They use it only for their own purposes. Most probably your server IP address has been blocked due to sending too many requests.

single client_id vs. user authorization for showing multiple instagram feeds on a website

I'm developing of a community website that features about 500 user profiles. We now want to add the option to show the users' Instagram feed on their profile (with their consent). Going through the instagram API documentation some questions arose concerning the right approach about permissions and the review process.
Can anyone clarify if the following is a working approach and a valid use case regarding instagram's policy: Creating one client ID / access token for the website that is used to communicate serverside with the Instagram API, using the public_content permission to query the members' timeline. Server side caching would ensure that the rate limits are respected.
Since we need read-only access to public content only we would like to avoid managing authorization of every single member.
Thanks!
In the recent API changes Instagram removed the ability to use the client_id for requests and now an access_toek obtained by authorising and Instagram account is required for everything
You could make an account for your website, authorize it and use its access_token, but it will need to apply for the public_content permission and I don't thin Instagram will like this use case. Also with 500 accounts you may hit your Ali request limit.
The better option is to require uses to authorise their Instagram account if they want their recent posts on their profile and use their token to get their recent posts. This way you don't need the public_content permission

Get historical data using Instagram API endpoints.

I am trying to fetch data using the Instagram API endpoints. Steps that I have followed
1. Register the client app.
2. Got the access token.
3. I am using this access token through out the url endpoints.
Ex. to get the data for recent media I am using this url endpoint: https://api.instagram.com/v1/users/self/media/recent/?access_token=ACCESS-TOKEN
However as I am in Sandbox mode, as per the documentation I get only the recent 20 media. Whereas my account contains in total 291 media.
Problems that I am facing:
Not able to get next_url in the paginationpart.
Usage of min_id and max_id in the url does not respond to any changes in the output or the data i.e fetched (Still get only 20 records/media)
Ex: https://api.instagram.com/v1/users/self/media/recent?access_token=XXXXXX&min_id=xxxxxx_xxxxx&max_id=xxxxxxx_xxxxxxx
Can anybody provide a solution as to how exactly I should get all of my historical data ?
You're in the sandbox mode so there's no way to achieve what you're trying to do before your app has been reviewed and approved (and gone live). From Instagram API documentation:
After your app has been reviewed and approved, you are ready to make it available to the general public. To switch your client from sandbox to live mode, you can use the button on the top section of the configuration screen for your app. When you are live, any Instagram user will be able to authorize your app, but you will have access only to the permissions that you were granted during the review.
Well, maybe you should try this library that allows you to scrape public info withou auth (client_id or access_token): https://github.com/raiym/instagram-php-scraper
$medias = Instagram::getMedias('kevin', 150);

get latest tweet of a user without authentication

I am creating a website using rails. there is no user authentication but all the team members data(name, summary of job experience, social media handles, etc) is saved in a json file which is parsed to show the data on page. I have a twitter handle of every user. I want to collect the latest tweet and the tweet's information(tweeted on, etc) for every handle. Also, if any of the user posts another tweet, that tweet should replace the old tweet. I dont have user authentication in my application. i did try on terminal
curl http://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=user_name&count=1
but it gives me
{"errors":[{"message":"Bad Authentication data","code":215}]}
All requests to Twitter's API now need to be authenticated. See the documentation for the API call you want to make.
You will need to register an app with Twitter and get your authentication tokens before you can start to make requests like that.
So, to be clear, the users do not need to be authenticated - but your app does need to be authenticated.

Accessing linkedin api without repetitive sign in?

I am new to linkedin api. I have a doubt regarding the api.
I am integrating the api in my application, so different user have to register in the linkedin to get the data using that api? Can it be pre registered and the user can get the data whatever he wants.
Suppose user wants to search about company. He will type the company name and will get the names of the company related to search. He should not log in in linked in before searching.
Is it possible?
If you are using the JavaScript API, then yes, you may need to have the user log in each time as the JavaScript API's authorization is cleared every time the user closes their browser.
If you are using the REST API, you can store the user's OAuth token and use that to make the calls on behalf of the user, saving them having to sign-in each time.