Graph API me/friends/ always return empty - facebook-graph-api

i used to create Facebook APP, checked to get friends list using Access token from Graph API Explorer, it always returning empty data

https://developers.facebook.com/docs/apps/changelog
https://developers.facebook.com/docs/apps/upgrading/
Check those Links, Facebook made a big step forward towards privacy. /me/friends only returns friends who authorized the App too, that´s why the result is empty.

With the introduction of the Facebook Graph API 2.0, access a user’s friends list was removed and limited to just friends who use the same application. However, Facebook added two new APIs to allow retrieval of Friend names (and indirectly a friend count). The two new APIs are taggable_friends and invitable_friends.

In v2.0 of the Graph API, calling /me/friends returns the person's friends who also use the app.
Check this link: Facebook Graph Api v2.0+ - /me/friends returns empty, or only friends who also use my app
When I login with ID my friend and retry send request "me/friends" again. It return ID my Facebook to me. If you need test, you can use this way.

I have currently find this one useful, just posting a snippet:
FB.ui({method: 'apprequests',
message: 'Please sign up .',
filters: ['app_non_users']
}, function(response){
console.log("Response from app requests:"+response);
});
Reference url https://developers.facebook.com/docs/games/requests/v2.1#params

Facebook was updated with version 2.0,
if you want to use Graph API me/friends/, you need to submit your app for review.
Steps to do it:
goto your Apps --> status and Review ---> start a Submission.
then you need to provide your information for review with screen shot.
Submit Items for Approval
Some Facebook integrations require approval before public usage.
Before submitting your app for review, please consult our Platform Policy and Review Guidelines.

Related

Migrating existing Login flow using Instagram Legacy API to the new Instagram Basic graph API

Our application (kind-of got legacy) has been using IG API to authorize users (by using the uid attribute returned from IG's callback API response) and we have left email as an optional param (safe to assume that there are many users in the application database without email IDs persisted)
With new Instagram Basic Display API (advised), it's mentioned to use Facebook Login for authentication purpose. But I am facing a major problem of identifying existing users now (since the uid will be different).
Also I have a doubt on what will have happen for users having instagram account without linking their Facebook account to it?
I could not find a proper explanation or a documentation for seamless migration for my situation.
Please help with sharing the right resource or guidance to achieve the same.

Extract my timeline posts from Facebook Graph API

I am trying to extract my posts, via Graph API from facebook. I used some basic code snippets but they don't work. I can not get my feed even in the Graph Explorer. It always says that I don;t have the permission and I have to submit my App for review and provide a video tutorial on how I use the extracted posts.
But I want to extract just my posts, I don't care for anybody elses. Do I seriously need FB App review to do that?
This is what I get with my token from my app:
user/posts requires additional contract signing:
Use /me/posts with your own App, with your User Token and authorize with the user_posts permission. This works without any approval from Facebook - for your account and your App only, of course. I just tested if it still works in the Graph API Explorer and it did: https://developers.facebook.com/tools/explorer/108138225915615/?method=GET&path=me%2Fposts&version=v5.0

JavaScript API call for "/me/friends" returns a response with empty list but correct summary

I do the call:
FB.api('/me/friends', function(response) { console.log(response);});
I see in the console log response as and object with empty data and correct summary:
Object { data=[0], summary={...}}
Where summary is (the number of my friends):
Object { total_count=444}
I know that friends edge call has been changed through APi v2.1. It works in Graph API explorer. I hve specified permissions for the requested operation before:
<fb:login-button scope="user_friends" onlogin="checkLoginState();">
</fb:login-button>
What am I doing wrong?
You misunderstand what the user_friends permission is for. This is taken from the docs about the user_friends permission:
user_friends
Provides access the list of friends that also use your app. These friends can be found on the friends edge on the user object.
In order for a person to show up in one person's friend list, both people must have decided to share their list of friends with your app
and not disabled that permission during login. Also both friends must have been asked for user_friends during the login process.
Review
Your app may use this permission without review from Facebook.
Common Usage
Use the list of friends to create a social experience in your app.

Corona SDK Facebook returns app_scoped_id and not my normal user_id

If I have understood it correctly Facebook made some changes so it returns app_scoped_id instead of the normal user_id.
The problem I have now is that no other function seems to work.
I receive an I id from Facebook, and it's the same each time I login, but if I use facebook.request("me/friends") the table is empty, if I use facebook.showDialog("friends") it
What do I need to do in Corona SDK to get this to work? Before I could use these functions after having setup them up in Facebook.
I read this thread explaining why this happen but it doesn't explain how to solve it in Corona SDK: Get Users App-Scoped user id in Facebook Graph API
As of Facebook API v2.0, friends list (/me/friend) returns ONLY user's friends who are already using your application. This limitation applies to all apps that are on v1.0 mode too.
If you're looking to get friends for tagging actions: https://developers.facebook.com/docs/graph-api/reference/v2.0/user/taggable_friends
If you're looking to get friends for inviting to a Facebook Game on Canvas: https://developers.facebook.com/docs/graph-api/reference/v2.0/user/invitable_friends
Cheers!

Facebook opengraph insights api on specific post id from my app

I want to build a dashboard that returns more customized insights from the insights generated by app.
The app is a facebook connect website that users visit and view a list of products. They can post to facebook about that particular product by sharing a custom story that incorporates that product on their timeline.
When I go to the insights for my app, it does a great job of showing me all social impressions for all custom stories that were generated on my site.
I'd like to narrow that down even more for specific products.
My plan is to record the object ids that are generated by these actions and link them to a partucular product in my database.
I'd then like to create a new dashboard page that will allow me to login, request read_insights permission from me and then use that object_id:product mapping from my database to show how many social impressions where recorded for a given product's object_ids.
Is this possible? I've read alot about it but still haven't found the most elegant way to get a segmented report of social impressions per type of content that was posted.
Thanks for your time.
The implementation all depends on which platform you want your app to run on.
The first major component is you must have a Facebook developers account which is easy to signup for. Just go to developers.facebook.com and register. Takes like 2 mins. After that you will need to create your first app and add the correct domain name where your app will be hosted and what platform it will run on. (iOS, Android, Web, ect.) Once that is finished you can make your app public so you can use the Facebook API in your code.
For the app creation itself. The first thing you need to do is import the correct API for your platform. Which you can find a walk through at https://developers.facebook.com/docs/. Once the API is imported you must build a Facebook object which contains your app id and possibly app secret. If you're using JavaScript you don't want to use the app secret because it will be visible to the public.
Now that you have your Facebook object you must require the app users to log in and grant permission to your app. You can add extended permissions to your log in process by adding a scope value to the log in button generated by Facebook. Here is an example.
<fb:login-button id="loginBtn" max_rows="1" scope="basic_info,read_insights,manage_pages" size="medium" show_faces="false" auto_logout_link="true"></fb:login-button>
After the user is logged in you can now query information from the users account using Facebook Api calls to Social Graph. Facebook also provides a tool to help you figure out what information you can query. https://developers.facebook.com/tools/explorer
Everything else you want to do with the app can be done by Facebook API calls. You just need to insure you grant the user the correct permissions before making the API calls.
API calls are a little different depending on which language syntax you are using but they all follow the same data model and return some array of responses which can be parsed using JSON or the standard array format. The Graph Explorer tool listed above will show you the output for your queries so you can handle them accordingly.
I hope this helps gets you started.
EDITED
Here's the implementation in JavaScript
function getMetric(){
// make the API call
FB.api(
"/{app-id}/insights/application_opengraph_story_impressions",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
}
Here's the reference now that Facebook docs are back up https://developers.facebook.com/docs/graph-api/reference/insights
application_opengraph_story_impressions will probably give you the total impression of all stories made by your app. I ran it against my Facebook app and it came back empty but I don't have any stories so it might work with your's. Also to note in the documentation there is an * by this metric and I could't find what that means.
I'm pretty sure that right now Facebook don't give developers ability to get insights about app custom stories.
Currently Facebook documentation has the following Graph APIs for Insights data:
/{page-id}/insights
/{app-id}/insights
/{domain-id}/insights
/{post-id}/insights (where this is a Page post)
So /{post-id}/insights won't work because custom story is actually user's post and others endpoints don't apply to your case.
As far as I know the only other option to access Insights is FQL. For that you'd use insights table in a manner similar to this:
SELECT ... FROM insights WHERE object_id = ... AND metric = ... AND end_time = ... AND period = ...
Now most likely this also won't work with your custom story posts (I don't have posts which I could try it on right now, so I can't tell) but at least it is not explicitly stated so in the documentation, so you should probably try it out.
UPDATE:
I wasn't able to get any insights data via FQL, although as far as I understand the following code should have gave me at least something (object id is for my page):
SELECT breakdown, end_time, event, metric, object_id, period, value FROM insights WHERE object_id = 224981264214413 and metric = 'page_fans' and period = period('lifetime') and end_time = 1395597892
But it results just in
{
"data": []
}
Facebook also has some pretty old bug report about similar topic: https://developers.facebook.com/x/bugs/508088155954330/ where they confirmed the issue, assigned it, and... did nothing to fix it for 6 months.
In case FQL doesn't work, my suggestion to you is - use your own analytics code to track the creation of custom stories and get the friend count of the users. It won't show you the real exposure of the posts but at least you will see some data on which types of custom stories where posted more often and what was the maximum potential friend count that could have seen them. By the way - to make charting easier, you could use Google Analytics events for that.