Can I get all posts from instagram based on a specific tag with the new Facebook Graph API? - facebook

Right now I am using Instagram API Platform with the "Public Content
- capabilities to read public media on a user's behalf" rights for my app. As it is stated on the website, it will be deprecated on December 11, 2018 and they are pointing to the new Instagram Graph API.
I went through the documentation but could not find what I need. I would like to know if it is possible with the new API to:
Get all posts info (user that posted, the number of followers, caption, likes count and the media itself). With the Mentions API from Instagram Graph API you can get all posts where your Business account is tagged #account, but they require media_id which I don't have, how do I get it?
Get all posts with a specific hashtag, of a specific user (non-business account) within a timeframe. From the comments it is clear that this is not possible for now. Still hope to get an answer to my first question.
I would like to know if the above mentioned are possible with the new API and it would be nice if you can point me to the right API. Thank you in advance

but they require media_id which I don't have, how do I get it?
You can get the list of media id's on which an account has been tagged using the tags endpoint.
v4.0/<account id>?fields=tags
Once you have the list of media items in which the account has been tagged, you can cycle through them and return the following fields each media post.
Returnable Fields: caption, comments, comments_count, like_count, media_type, media_url, owner — The ID of the user who owns the object., timestamp, username
With the owner ID of the post you might be able to look up more of the fields you are looking for, but you will likely run into some permission issues.

Related

Which Instagram API should I use to collect public data?

Does either the Instagram Basic Display API or the Instagram Graph API allow me to simply get any public user's posts/media programatically? Everywhere in the documentation it says "User data" but it feels like I can only get data of the user that got authenticated using the API. I've set up a Facebook dev account and currently spending 4th hour on calling both APIs without success. Can anyone who has used them help me clear this up?
Most likely, Instagram API Date 365, a tool I currently work for, may help you as an alternative to using Instagram Basic Display API or the Instagram Graph API because this API is created especially for scraping bulk data about posts and users.
You can get such post data as post content (text, language, list of hashtags, list of tagged users), owner ID, location ID,
engagement info, etc. Also, it is possible to download comments (selected or on a specific post) and replies to them.
You can view this for more info.

How to get media of specific instagram account by hashtag?

I want to get media of specific Instagram account (my account) by hashtag. I followed the instruction of Instagram Graph API but maybe the result maybe returned all media of all user by hashtag.
Does anyone have any idea ? Thanks !
Reference: https://developers.facebook.com/docs/instagram-api/hashtag-search
If I understand you correctly, you want to get all of an Instagram business account's posts that include a particular hashtag? One can use the call:
<INSTAGRAM_BUSINESS_ACCOUNT_ID>/media?fields=caption
To get an Instagram business accounts posts, including the caption. Then, one can parse the caption field to derive what hashtags were used in each post.

Is it possible to get all user id's who have shared a specific post, through graph api or any other resource?

I am looking for a way to record user id's of a public post for a brand. If there are any resources available, any help would be appreciated.
Retrieving share data with FB API doesn't seem to be officialy supported by Facebook, but you can retrieve posts shares with Graph API, just do the following:
Get the ID of your post (eg. /me/posts query)
Split the ID on underscore character and get the second part (first part indentifies posts author)
Query the shares: [id_2nd_part]/sharedposts
Note that since it's not officialy supported it may stop working at some point in the future
You can test it with Graph explorer - to get shared posts you need read_stream permissions on your access token if I'm not mistaken

Facebook Graph Api json missing posts

I am developing an web app, which connect to facebook, to get posts, and other stuff liked by users. I have problem with getting all posts from user page using news feed(home connection of Grap API).
When getting access token in my app for user, I ask for read_stream, user_activities and offline access permissions. Then, when I use that token, to get json feed for
https://graph.facebook.com/me/home/?access_token=<retrived_access_token>
some posts(which are show on user page) are missing. I found that posts of my friends, which can be seen only by their friends, are not shown in that feed. The same issue is with posts of users which current I am subscribing.
I was searching on that for a while, and I found, that when I use link from http://developers.facebook.com/docs/reference/api/ to get my news feed, there are much more posts. It's seems to use a token generated for test console app for facebook api.
Then I tried to generate access token which would give me similar results using http://developers.facebook.com/tools/explorer?method=GET. But even when I give to generated token all possible permissions I could not get it working good, there were still some missing posts.
I read answer in that post, Facebook graph API does not return all posts for user, which suggested, that this is because of permissions set by my people who publish posts, who don't want their data to be retrieved by an app. I run some quick test, and I found that changing that setting is working( when somebody change that setting her posts will disappear from both feeds - that using my app token for user, and that under link on api reference page), but it's not the case.
It seems that this token generated on api reference page have an special permission.
I really need to get as much posts from user page as possible. I know that I will not get those blocked by their author, but as many of my users subscribe other users I really need to get access to kind of posts shown on user page.
I also read Facebook graph API: feeds missing in json response but it was also not helpfull.
I will really appreciate any help.
It is impossible to get a full list of posts from the feed / home Graph API, but you can use FQL to query the stream table to get almost every post made by friends, here is a quick example of how you would do that with the javascript sdk:
var query = 'SELECT post_id FROM stream WHERE filter_key = "others"';
FB.api('fql', {'q': query}, function(posts) { console.log(posts.data); });
This will get you the post ids, which you can then use with graph api to fetch the rest of the post info. Or you can get the full list of fields here, you can't select * in FQL so you'll have to list each piece you want and then get comments and likes and names separately.
There is an assigned/medium bug on this at http://developers.facebook.com/bugs/228057243915183. You can bump up the priority by subscribing and indicating you can reproduce it.
Also see http://developers.facebook.com/bugs/231621496918030 where Facebook has said "the stream table and me/graph have limitations. See the documentation for more info. We're trying to make this more clear in the future." Personally I don't think there is really any more info in the documentation though.

What is the difference between feed, posts and statuses in Facebook Graph API?

I'm trying to write a program that retreives a given user's "statuses" (and by statuses I mean the things he posted himself, anything he wrote as I'm mostly interested in textual statuses)
I cannot figure out the difference from the documentation here https://developers.facebook.com/docs/reference/api/user/ so I don't know which connection type to use; feed, posts or statuses
(Another thing I noticed is that statuses requires an access_token while the other 2 require the access_token only for non public stuff)
Thanks
This is documented on the User object of the Graph api. And, as of the Graph API v2.6, there is basically one main endpoint from which you get posts from a user.
/{user-id}/feed includes all the things that a user might see on their own profile feed; this includes, e.g., shared links, checkins, photos and status updates. This also includes posts made by friends on the user's profile.
The following endpoints return subsets of the above:
/{user-id}/posts returns the posts created by the user (on their own profile or the profile of a friend), and it may include any kind of content such as shared links, checkins, photos and status updates.
/{user-id}/tagged returns the posts created by friends and shared on the users's profile.
By default each returned post only includes the story field with a textual description of the post. But you can use the ?fields=... parameter to request as many Post fields as you want.
You'll need the user_posts permission for any of these to work.
The following endpoints are deprecated:
/{user-id}/statuses returns only status updates posted by the user on their own profile. [removed after Graph API v2.3]
/{user-id}/home returns a stream of all the posts created by the user and their friends, i.e. what you usually find on the “News Feed” of Facebook. [removed after Graph API v2.3]
I've found one more difference between /statuses and /posts. /statuses are just text statuses (it doesn't include shared links)
Feed - https://graph.facebook.com/me/feed - gives you the user's feed - meaning the posts he sees when he is visiting facebook (friends important posts) - notice that facebook filters only things it's algorithm marks as significant to the user and not everything.
Status - what the user posts on his own wall
Posts - what the user posts - including on other people's walls