Instagram ?__a=1&max_id=<end_cursor> isn't working for public user feeds - api

I've been using Instagram's undocumented API https://www.instagram.com/<user>/?__a=1 to get a public user feed.
I was also able to get multiple pages via their max_id query parameter like so: https://www.instagram.com/<user>/?__a=1&max_id=<end_cursor>
end_cursor = json_response.graphql.user.edge_owner_to_timeline_media.page_info.end_cursor
(yes, "has_next_page" is true)
They had a recent change to their JSON format and I think they might have broken other functionality.
The "end_cursor" is still there but when I use it I just get back the same Instagram posts as if I wasn't using it.
Just to make sure I'm clear, my issue is that the max_id=<end_cursor> doesn't seem to work anymore for a public user feed. I can still get the first 12 posts, but no more after that.
Anyone else seeing this problem?
here's a JSFiddle example of what I mean:
https://jsfiddle.net/LLsg91ja/33/

04-14-2018 - NO LONGER WORKING - INSTAGRAM DEPRECATED THE '?__a=1' & '?query_id=17888483320059182' - THIS NO LONGER WORKS!
Okay take a look at this for media pagination:
https://instagram.com/graphql/query/?query_id=17888483320059182&id=<user_id>&first=12&after=<end_cursor>
This returns:
['data']['user']['edge_owner_to_timeline_media']['page_info']['end_cursor']
And Media:
['data']['user']['edge_owner_to_timeline_media']['edges']
the 'query_id' is static now so just use: 17888483320059182
'id' is the "instagram user id" so you have to use ?__a=1 to grab ['graphql']['user']['id']
'first' is the number of photos you desire returned. Just use 12 to keep the media return the same.
'after' is the new 'max_id' for use ['data']['user']['edge_owner_to_timeline_media']['page_info']['end_cursor']
I'll test more and respond later.
Responding Later:
It is believed 'pagination' using ?__a=1 has been deprecated. If true then there is no answer which can solve the op's direct question using ?__a=1 for Instagram pagination.
But the code provided in this answer will provide the pagination of Instagram media which does provide the results the op was seeking.
The answer incorporates the 'instagram graphql api' which is the current api (and not the json ?__a=1 hack) so this answer should provide some stability for now.
As used on my live site:
Grab the id=<instagram_user_id> prior the Instagram media request:
profile = https://www.instagram.com/<instagram_username>/?__a=1
media = https://instagram.com/graphql/query/?query_id=17888483320059182&id=<profile['graphql']['user']['id']>&first=12&after=<end_cursor>

You can use this: ?__a=1&page=3

Related

Facebook graph API can't break down by asset

I'm trying to get a breakdown at image and video asset level with Facebook graph API, but whenever I add image_asset or video_asset the response becomes empty, is there anything I am doing wrong or is there some API limitation I should know about? I can't find anything in the docs:
With country breakdown it works fine but when I switch to image_asset or video_asset I get a response like this:
{
"data": []
}
After discussing with FB we have solved a similar issue on our end. Perhaps it is the same for you: It can happen that a campaign in settings has 'dynamic creatives' turned off - in this case no data will be returned by the dynamic creative breakdown (as there is no data), but other breakdowns will provide data, which seems like it is the case for you. You can solve it by just retrieving ad data and then getting the creative data you need related to this ad. Hope this helps!

How to search and filter tweetts using Twitter API?

I am exploring how to search and filter tweets using the Twitter API version 2 which as of this writing has been newly released. The documentation for this particular endpoint is available here.
I tried successfully searching for the following query:
https://api.twitter.com/2/tweets/search/recent?query=puppy
As I needed to be more specific, I checked out v1.1 docs for rules and filtering and tried to look for tweets containing puppy images (filter:image) and no retweets (-filter:retweets) but I could not get the query in v2 (preferably) or v1.1 working with postman even though I tried percent-encoding for the special characters.
It is also not clear to me from the documentation (though mentioned in the docs) how to specify a certain language like English (lang=english) and a certain distance in the query "37.781157,-122.398720,1mi"
Does somebody know how to pass it into the query?
For language filter you can refer the post
https://community.postman.com/t/define-the-language-of-tweets/20643
But I am not sure about the image filter. But in recent times a developer sean.keegan from Postman is talking more about twitter API's in Postman. Please do check out https://community.postman.com/search?q=twitter and https://www.youtube.com/watch?v=ySbLo13Fk-c
I hope these will be helpful for you!!

Google+ HTTP API returns less activities than supposed to

I've been using Google Plus HTTP API for several weeks now and I'm experiencing a strange issue.
When I try to retrieve public activities from this community: https://plus.google.com/communities/115653528125420367824, I always get 4 results, no more. I've tried increasing the maxResult parameter of the request but it doesn't change anything...
And when I use the nextPageToken to retrieve the missing activities, the "items" field of the response is empty.
You can try it yourself with the Google APIs Explorer here: https://developers.google.com/apis-explorer/#p/plus/v1/plus.activities.list?userId=115653528125420367824&collection=public you will see that only 4 activites are returned and the next page of result is empty.
This is really strange and happened recently, it used to work fine. Maybe it is caused by the fact that the content of some activities of this community contains a stringified JSON object. What do you think?
The activities methods are only supported for retrieving posts by users and Google+ Pages. They are not supported for use with Communities and should not be expected to work correctly. There is definitely no guarantee that this behavior while it might have worked or currently works in some cases today will continue to work in the future.

Google+ .Net API - Getting Authenticated and retrieving profile

I'm trying to get a users profile information for google+ via the .NET API but am having trouble.
Does anyone know if they have changed how the special ID "me" works?
In the documentation it says this can be used as a special ID to get the currently authenticated users information however this throws a 404 from both the API in my code and on Google's own test page https://developers.google.com/+/api/latest/people/get. I was logged in when trying this.
Does anyone know how to get the user ID as I would happily use that instead of me but it isn't returned after the user authenticates as far as I can see (just an authcode)?
I also tried using user IDs returned when using the standard .net Oauth stuff but it isn't the correct ID, I assume it is for something else.
As for my method of getting to this stage, I first downloaded the example files here: http://code.google.com/p/google-api-dotnet-client/wiki/GettingStarted
They don't have a plus example so I took the Tasks.ASP.NET.SimpleOAuth2 example and swapped out tasks (which worked fine) for the plus equivalent.
I also tried rolling this into my own project.
Neither worked. I get the user forwarded to Google where they give me access fine and then when I return they are authenticated successfully as far as I can see, however when I call service.People.Get("me") it returns a 404.
If anyone could help with the above questions (using me, or gettign the user ID) I would appreciate it.
To the moderator who closed the initial version of this question, I have tried to make this as direct a question as possible so please don't close it. This is a legitimate question I would really like help getting to he bottom of.
This is now out of date given recent platform updates. Although the plus.me scope still exists and this code will work, you should be using the plus.login scope for retrieving profile data in C#. For a great way to get started with retrieving and rendering profile information, please start from the Google+ C# quick start available here:
https://developers.google.com/+/quickstart/csharp
First off, the 'me' id still works and is unchanged. The way that it works is:
You authenticate the user using a standard OAUTH2 flow
You use the library to perform a People.get with the special value 'me'
The 404 error code is a little troubling, this means that the client isn't finding the endpoint. To debug this, you might want to use a packet sniffer like fiddler to see what the actual URL it's querying is.
Anyways, how about some C# code. The following example shows how to use the plus service to get the currently authenticated user (assuming you have authenticated someone). What's different from your snippet is that you need to form a get request for the API call, then run fetch on the get request. I've included the following example, for getting 'me', and the following code works:
var auth = CreateAuthenticator();
plusService = new PlusService(auth);
if (plusService != null)
{
PeopleResource.GetRequest prgr = plusService.People.Get("me");
Person me = prgr.Fetch();
}
All of the configuration of the server and getting a client working is pretty hard and pasting all of the code here would be less helpful than just giving you a sample.
And so... I have written a sample application that demonstrates how to do this and also includes a wrapper that makes it easier to develop using the Google+ API in C#. Grab it here:
Google+ C# Server-Side demo and library
Seems you need to use:
Person test = service.People.Get("me").Fetch();
and not
req = service.People.Get("me");
Person test = req.Fetch();
Even though they seem to be identical the first works and the second doesn't.
Still not sure why google's own page doesn't work though. Now to find out how to add things to the scope like birthday.

Graph API not returning image/picture for community pages

Graph API is not returning image("picture" attribute) for objects corresponding to community pages, which used to be returned earlier. For example this https://graph.facebook.com/178790412179919 does not have picture attribute whereas the corresponding page has an image.
Also the FQL query done on the "albums" connection for some objects does not have a "cover_pid" attribute for an album corresponding to type "profile", which again used to work earlier.
Does anybody know if anything has changed in Graph API corresponding to this in last couple of weeks (I am fairly confident it used to work earlier in the expected way). I looked through Facebook API release notes but could not find any changes corresponding to this. Please let me know if this not appropriate post for this forum.
https://developers.facebook.com/docs/reference/api/page/
picture is a connection, not an attribute. So ...
https://graph.facebook.com/178790412179919/picture
And as the docs say: Returns a HTTP 302 with the URL of the user's profile picture.
Kinda goofy? Yes, but it works exactly as the docs say it does. I suspect they implemented it this way so it could easily be used in an <IMG> tag.
UPDATE:
It still works via FQL. In your case:
https://api.facebook.com/method/fql.query?query=SELECT+page_id%2C+pic+FROM+page+WHERE+page_id+%3D+178790412179919&format=json
I can confirm that this PREVIOUSLY worked, but NO LONGER works. Facebook have removed the picture connection from Community Pages.
I suspect the reason is that most of these images are pulled from Wikipedia, and there was a licensing / attribution issue.
Unfortunately, Facebook is no longer a reliable source of images for entities (e.g. bands).