Using the Twitter API, how to ensure a tweet comes from a specific source - api

If I want to ensure that the tweet comes from a specific service (using Foursquare for example), what is the best way to accomplish this using the API? Is the Users field enough, if I know the ID of the user?

Each Tweet returned by the Twitter API contains a source field. The source attribution of a Tweet is set by the name of the application used to create it e.g., Foursquare. So that's the field you should be looking for.
You can see source data in the example API output on this page:
https://dev.twitter.com/docs/api/1.1/get/statuses/home_timeline

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']

Instagram API - Is it possible to search for a users hashtag posts

Is it possible to search all posts with a specific hashtag by a certain user?
I am new to development and I am trying out Instagram's API if I can search such combination.
It is possible, but not using only a single request to Instagram's API. There are two solutions:
Search for posts by given hashtag's name using GET /tags/{tag-name}/media/recent request and then manually check every post if its user is the user you want.
Search for posts by specific user using GET /users/{user-id}/media/recent request and then manually check every post if its tags array contains the specific hashtag you want.
I would recommend to choose the solution in which you can expect less results (posts) to filter. In most cases it means the second one, because there is more posts on Instagram with a specific hashtag than an average user share on its Instagram's accout.
You can test Instagram's API requests with Instagram's API Console: http://instagram.com/developer/api-console/

Is it possible to get instagram media for a location with a foursquare id in a single call?

I have a bunch of foursquare ids and I want to be able to pull instagram media with those foursquare ids.
Currently I only see one way to do this and it requires two API calls. You must first do a call to the search API using foursquare_v2_id (example call). That will return the instagram ID. Then I must do a second call to the media API using the instagram id to retrieve media (example call).
Does anyone know how to achieve these results (getting media for a location based on just a foursquare_id) with only one api call?
You can get this information through the foursquare API, with the venues/photos endpoint. See the documentation here.
This will return a list of photos for the venue, including their source. You can use this to either return all images for a venue, or just those from instagram.
After contacting Instagram it is clear that there is no way to do this at this time. If that ever changes I will come back and re-answer this question with the proper solution.
I think you have to user below api to get instagram images:
https://api.foursquare.com/v2/venues/423a1a00f964a5202f201fe3/photos?oauth_token=Z5RRDGQUWEAFCANX2OT0R2O5QUWYOP1EMOCNXT1PQWKMHVNG&v=20130706&limit=200
Using foursquare id and foursquare oaurh token you can get perticular venue images.
In response, you can check "source":{"name":"Instagram","url":"http://instagram.com"}.
source name is Instagram means it is a instagram image.
Refer: https://developer.foursquare.com/docs/venues/photos

Get tweet from the user?

What is the best way to get twitts from the user on iPhone. Is it possible to get twitts with help of search twitter API? twitter search api doc
I need load more than 20 twitts.
Tweets are returned from Twitter's servers in JSON format. There are a half-dozen JSON libraries for cocoa, all very good.
Fetching tweets can be done using a simple URL request, for unauthenticated tweet data (e.g. users tweets are public). e.g. http://api.twitter.com/1/statuses/user_timeline.json?screen_name=sn00ki&include_entities=true
Or if you need access to tweets that might be private, you are going to have to log in, probably using OAuth. I would suggest a twitter library. MGTwitterEngine, for example.
If you can go iOS 5 only, you can use the new built in Twitter Framework