fetch user media from instagram api without user id - api

I'm working on an instagram web client and i'm trying to get users media to come up if I type the user's username in the address bar. Also I don't want the user's id to show in the address bar. here's the site - http://writethefuturegroup.com/photo-client/. To get the user's media, I passed the ID in the address. But if you go to other web clients the ID doesn't show in the address bar and you can get a user's media by just entering their username in the address bar. I would like to know how this is done.

You will have to make 2 API calls to get user media by username, first use search API to search for the username, if the username exists then it will be in the API response, use a IF statement to check that the username matches and then get the corresponding user ID, use this ID to make another API call to get user media.
First use the user search API endpoint https://api.instagram.com/v1/users/search?count=1&q=USERNAME to search the username,
In the API response if the user.username == USERNAME you searched for, then get user.id
Make another call to get user media using the user id, use the API endpoint: https://api.instagram.com/v1/users/USER-ID/media/recent/

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.

How to get the user's name from the Instagram API?

The Instagram Basic Display API "allows you to get a user's profile" though is there a way to retrieve the Full Name of the user?
https://developers.facebook.com/docs/instagram-basic-display-api/reference/user
The link above shows that you can return the username but cannot get anything meaningful such as their Name, website or Bio - though you are able to get all of their media.
I believe it is possible with the Graph API (which is for professional accounts) but is there a way to do so with the Basic Display API?
The easiest way would be to send a GET request to https://instagram.com/{username}/?__a=1. You'll find what you need inside ['graphql']['user']

twitter's user search api:- search using email id

I am working on a requirement where I need to fetch user profile from various social media sites. For example, I can use the twitter's user search api to fetch user profile using the user name. But i have only email address and want to fetch user profile data from twitter using email address. I found out that twitter's api does not support user search based on email address. Similarly facebook API also does not support user profile search based on email ID. Is there any other way to fetch the user profile data from these websites using email Id's?

Can I get the email address from a user sign-in with the Twitter framework in iOS 5+?

I have a requirement in my app to sign up with Twitter, so for a first time user, the server stores (among other things) email, password, first name and last name.
But the only things I can get from the Twitter/social framework is the profile id, username, first name and last name. Is there any alternative for getting the email address, or will I have to change the signup mode in my server's app?
Unfortunately it seems that we cant get email address from twitter, so I had to change my signup mode by validation through the twitter login and users profile id. If anybody else has found a workaround please do post your solution. I'll mark that as best answer.

Find Google+ avatar for given email address without OAuth

In my app I want to show the Google+ profile picture for a user.
The only function, I found, in the API to get the profile picture needs a userId.
However, I only have their email adress and not their Google+ userID.
Moreover the person, whose image I want to get, should not be forced to log in and authorize my app, as this person is mostly not identical to the user of the app.
So I think I need to get their userId by email. I read through the Google+ API documentation but can't find a way to do this, but I can't believe that this is not possible.
So my question is:
How can I get the Google+ userID with only an email address?
Is there maybe an other Google API to get a profile picture?
There is an API provided by https://www.avatarapi.com/ which returns the user's name and profile pic from an email address based on Google's public info.
It can be called via SOAP or HTTP at this API endpoint:
https://www.avatarapi.com/avatar.asmx
One of the benefits of this API is that it does not require the user to be authenticated with Google via OAUTH, so this could be exactly what you are looking for.
You can't do this using just their email address, however, if they paste their Google+ url, you could parse the id from the URL string and then get their profile image (and cover image!) using the public data API. The url: https://plus.google.com/me will bring you to their profile.
I highly doubt this is possible. Any kind of querying against the Google Plus API requires OAUTH. What's more, I'm not aware of way to query for a user ID by email address in the first place.
This thread would seem to confirm that this is currently not possible.
You can use the people.search API to search by email address and without requesting the user to authenticate. However, that will only search the public profile fields, which email is not a public field by default.
The only API methods that require OAuth are those that access private data. For public data, you can use the more simple API key method.
To reliably achieve what you are describing, you'll want to use Oauth and the plus.me scope to get the information that you want. This does require authorizing your app however.