Facebook graph api me/events returns blank - facebook

I'm using the Graph API Explorer and have given permissions for user_posts, user_likes & user_events.
me/posts and me/likes return non-empty data, but me/events returns this:
{
"data": [
]
}
I do have ongoing and upcoming events (interested) and they are visible on my Facebook profile.
Any idea what's going wrong? Or is it a Facebook bug?

https://developers.facebook.com/blog/post/2018/04/04/facebook-api-platform-product-changes
Testing of our more robust process starts today and the new process
should resume in a few weeks, but apps currently accessing Events and
Groups APIs will lose access today.
This may also be interesting for you: https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#events-4-4

Related

Facebook friends request returns empty -- despite permissions [duplicate]

This question already has answers here:
Facebook Graph API v2.0+ - /me/friends returns empty, or only friends who also use my application
(8 answers)
Closed 6 years ago.
I'm building a Rails backend for an iOS app. The backend needs to interface with Facebook to grab and use each user's Facebook friends.
But the Facebook 'friends' request is returning empty.
I'm essentially making the following request:
curl https://graph.facebook.com/[FILTERED_USER_ID_FOR_APP]?fields=friends&access_token=[FILTERED]&debug=all
I've looked at a ton of StackOverflow posts about this (this one, and this one, and this one, and more), but haven't found an identical problem or a solution that fits.
I seem to have set permissions correctly. Both on the Rails app and when the user authenticates through the iPhone app, I've set user_friends to be one of the permissions, and, in fact, when someone registers now, it asks them to OK the user friends permission.
But when I actually request their friends, I get a response telling me that there are many friends, but not returning any of them. The below response is for a user who definitely has friends on the app.
{
"data":[],
"summary": {
"total_count": 419
},
"__debug__": {
"messages": [
{
"link": "https:\/\/developers.facebook.com\/docs\/apps\/versions\/",
"message": "No API version was specified. This request defaulted to version v2.7.","type":"warning"
},
{
"link": "https:\/\/developers.facebook.com\/docs\/apps\/changelog#v2_0",
"message": "Only friends who installed this app are returned in API v2.0 and higher. total_count in summary represents the total number of friends, including those who haven't installed the app.",
"type": "info"
}
]
}
}
What's perplexing to me is that a) The App ID/User ID/Access Tokens seem right, because I can get basic profile info, and b) I do not get an error telling me that the request doesn't have the proper permissions. If I make a similar request without permissions on the explorer, it returns a relevant debug note:
{
"message": "The field 'friends' is only accessible on the User object after the user grants the 'user_friends' permission.",
"type": "warning"
}
If I make it with the right permissions in the explorer, it returns a list of friends (in the data array).
So it doesn't seem to be a permissions issue, but the request is returning an empty friends list. Any ideas?
With Igy's help (pointed to this answer), I found the specific answer to my issue, which seems worth adding here.
The problem was that the new 2.0+ API version only returns friends:
Who are on the app
Who have agreed to the user_friends permissions themselves.
1 was all figured out, but because I'm still testing the app out, and nobody had yet accepted permissions, my test user was the only person who had accepted permissions. Nobody else had accepted user_friends, so nobody showed up as a friend of the test user. Getting a friend of the test user to add the permissions fixed the problem, adding that friend to the list of friends returned.

Generate access token Instagram API, without having to log in?

So I am building a restaurant app and one of the features I want is to allow a user of the app to see photos from a particular restaurant's Instagram account.
And I want a user to be able to see this without having to login to their Instagram account, so they shouldn't even need an Instagram account for this to work.
So I have read this answer How can I get a user's media from Instagram without authenticating as a user?
And I tried what it said and used the client_id(which I recieved when I registered my app using my personal Instagram account), but I still get an error back saying :
{
meta: {
error_type: "OAuthAccessTokenException",
code: 400,
error_message: "The access_token provided is invalid."
}
}
The endpoint I am trying to hit is :
https://api.instagram.com/v1/users/search?q=[USERNAME]&client_id=[CLIENT ID]
So do I absolutely need an access token for this to work(and thus have to enforce a user to log in) ?
If I do, then is there way to generate an access token somehow without forcing the user log in?
I believe there is a way around this, as the popular dating app Tinder has this desired functionality I am looking for, as it allows you to see photos from people's Instagram account without having to log in! (I have just verified this 5 minutes ago!)
Any help on this would be much appreciated.
Thanks.
Edit April 2018: After facebook privacy case this endpoint is immediately put out of service. It seems we need to parse the JSON embedded in <script> tag directly within the profile page:
<script type="text/javascript">window._sharedData = {"activity_counts":...
Any better ideas are welcome.
You can use the most recent link
GET https://www.instagram.com/{username}/?__a=1
to get latest 20 posts in JSON format. Hope you put this to good use.
edit: other ways aren't valid anymore:
https://www.instagram.com/{username}/media/
Instagram used to allow most API requests with just client_id and without access_token, the apps registered back in the day still work with way, thats how some apps are able to show instagram photos without user login.
Instagram has changes the API specification, so new apps will have to get access_token, older apps will have to change before June 2016.
One way you can work around this is by using access_token generated by your account to access photos. Login locally and get access_token, use this for all API calls, it should not change, unless u change password,if it expires, regenerate and update in your server.
Since the endpoints don't exist anymore I switched to a PHP library -
https://github.com/pgrimaud/instagram-user-feed
Installed this lib with composer:
composer require pgrimaud/instagram-user-feed "^4.0"
To get a feed object -
$cache = new Instagram\Storage\CacheManager();
$api = new Instagram\Api($cache);
$api->setUserName('myvetbox');
$feed = $api->getFeed();
Example of how to use that object -
foreach ($feed->medias as $key => $value) {
echo '<li><img src="'.$value->thumbnailSrc.'"></li>';
}

Fetching a Facebook page's events?

I am trying to fetch a Facebook page's events. I have before, but it doesnt work any more. I used this scriptto fetch the events.
$string = file_get_contents("https://graph.facebook.com/?$pageids&fields=events.limit($fblimit)&access_token=$token&method=GET");
$json_a=json_decode($string,true);
$pageids was a lot of different facebook ids (id1,id2,id2 ...)
I get this error message:
{
"error": {
"message": "(#100) Unknown fields: events.",
"type": "OAuthException",
"code": 100
}
}
Does anyone know what is wrong with my script? Is there a another way to fetch Facebook events?
The actual URL to get a page's events is something like this :
https://graph.facebook.com/PAGE_ID/events
I'm not sure how old the code is that you are fixing, but this is the correct method as stated in the documentation. events is a connection of the page object.
Reference: https://developers.facebook.com/docs/reference/api/page/#connections
Facebook has had restricted access of Events in API recently.
You have to do app review to have access to Pages API, Events API.
Please check section "Apps that Require App Review, Business Verification, and Supplemental Terms" of this url: https://developers.facebook.com/docs/apps/review

Retrieving facebook user wall posts through graph API

I'm currently working on a facebook app which captures wall posts for a specified user, page or group, after a user has authorized the app I quote the access_token that is returned to call the method
https://graph.facebook.com//feed?access_token=
this works fine for pages and groups as we only need a valid token, however for users the results are different depending on the relationship between the user who authorized the app the user whose posts are being captured.
For example if there is no relationship between the two users some posts are not returned even though they are public and displayed when you view the profile of the user, however if they are friends more posts are returned.
Can someone please explain this behaviour? And is it possible to obtain all posts using this method?
Yes, per the permissions listed at https://developers.facebook.com/docs/reference/api/permissions the results of the call are different depending upon the relationship.
However when things are public and you use an access token that doesn't belong to the user, then no results are returned. I cannot remember a time when this wasn't this way. For some odd reason (by design or omission on Facebook's part) using the graph API to get at public posts using a user access token just doesn't want to work.
For example, You can see some public items here
http://www.facebook.com/zuck
http://graph.facebook.com/zuck
However, you cannot seem to get any feed from here without an access token
https://graph.facebook.com/zuck/feed
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException"
}
}
Let's try adding an user access token that does not belong to zuck or a friend of zuck. https://graph.facebook.com/zuck/feed?access_token={UserAccessToken}
And here's what we get:
{
"data": [
]
}
What about an app access token? Let's try
https://graph.facebook.com/zuck/feed?access_token={AppAccessToken}
{
"error": {
"message": "Invalid OAuth access token signature.",
"type": "OAuthException"
}
}
So as you can see, it's difficult to get things via the graph that are not in alignment with your access token.
I manage to get most of the feeds from user's wall post. Although this is a old post, I hope someone can manage to get what they want from my answer.
Before getting the access token(to get the feeds), you need to add multiple correct Read Permissions "keys".
For example, you will have to add "read_stream", and "user_status" (which I found that these are the most important permission "key" to generate the correct access token, to retrieve one's so-called "public" feeds).
You can add more into generating the access token, in either you want the permission to GET, or POST, or BOTH.
Source is here: https://developers.facebook.com/docs/howtos/ios-6/#nativeauthdialog
One thing that I found is, the way to get the feeds result from user's "Home/About" page and Facebook Page (which is created for people to like (not add friends)) are different. The key is mentioned above, "read_stream", and "user_status". So it's better that you add both of the permissions in order to generate the access token to get everything in feeds.
Graph API doesn't return posts to the App if is not authorized to read user feed, even if posts are public.
Source: https://developers.facebook.com/bugs/290004301178437/
According to the latest api ,
FB.api("/me/feed","get",function(response) {//callback})
should do and also work well .
It is working now but facebook may change it in future.

Facebook API checkins not working?

Wondering if anybody has had any problems using the facebook graph api to get checkins.
https://graph.facebook.com/me/checkins?access_token=2227470867|2.SOgfV3_Dc6iX_IzJctERXA__.3600.1292436000-666790342|UPcbXaafo7G5rd2I_7d9_LpeZFo
returns
{
"data": [
]
}
and any other ids insted of "me" return the same.
Anyone have any ideas?
Turns out you can't access the fb places api outside the US
Allright fellows,
after some tries I can shed a light to this topic, here comes the description of the solution.
You can make such requests only by authorized apps.
I implemented the flow on Android and works like a charm,
here is an example call grabbed from logs:
https://graph.facebook.com/me/checkins?format=json&sdk=android&access_token=<access_token>
important note: access token MUST have been retrieved by your application, which has permissions for
"user_checkins", "friends_checkins"
getting access token is straight forward flow, explained well in all SDKs (p.s. I'm using Facebook-AndroidSDK)