Programming
Facebook Graph API v20 - mefriends returns empty or only friends who also use my application
Connecting with friends is a core part of the Facebook experience. Many developers leverage the Facebook Graph API to integrate this social connection into their applications. However, a common issue developers face with the Graph API v2.0 and later versions is the /me/friends endpoint returning an empty data set or only listing friends who also use the application. This change, introduced to enhance user privacy, often causes confusion and frustration. This article will explore why this happens, what it means for developers, and how to navigate this new landscape effectively.
The Shift in Facebook’s Friend List Permissions
Prior to v2.0, the /me/friends endpoint returned a comprehensive list of a user’s Facebook friends. This allowed developers to build rich social experiences within their apps. However, concerns about user privacy led Facebook to restrict the data returned by this endpoint. The change aimed to give users more control over how their friend list data was shared with third-party applications. Now, /me/friends primarily returns friends who have also authorized the app, significantly limiting its functionality for many use cases.
This shift reflects a broader trend in the tech industry towards stricter data privacy regulations. As users become more aware of how their data is used, platforms like Facebook have adapted to meet these evolving expectations. This change, while challenging for developers, is ultimately a positive step towards protecting user privacy.
Understanding the user_friends Permission
The key to accessing a user’s friend list (with their consent, of course) lies in the user_friends permission. However, this permission is now considered highly sensitive and requires a rigorous app review process by Facebook. Only apps that demonstrate a genuine need for this data and adhere to strict privacy guidelines are granted approval. Simply requesting this permission doesn’t guarantee it will be granted.
For instance, apps that facilitate direct communication or social gaming might justify the need for user_friends. However, apps that merely want to display a user’s friend list without a clear functional purpose will likely be rejected. The emphasis is on providing users with a valuable and privacy-respecting experience.
Alternatives to /me/friends
Since obtaining the user_friends permission is more challenging, exploring alternative approaches to achieve similar functionality is crucial. While not a direct replacement, the Taggable Friends API can offer a viable solution for certain use cases. This API allows users to tag friends in content shared within the app, providing a more limited but still useful social interaction.
Another alternative involves focusing on features that don’t rely on complete friend list access. For example, instead of displaying a user’s entire friend list, an app might allow users to search for specific friends and invite them to use the app. This approach respects user privacy while still enabling social connection.
Building User Trust and Transparency
Clearly communicating your app’s data usage policies is crucial in the current privacy-conscious environment. Users are more likely to grant permissions if they understand why your app needs them and how their data will be handled. A transparent privacy policy and clear in-app explanations can significantly improve the chances of obtaining necessary permissions.
Consider providing users with granular control over their data. Allow them to choose which friends, if any, are visible to your app. This level of control builds trust and empowers users to manage their own privacy settings. Remember, transparency and user control are key to building a positive user experience.
- Focus on user privacy.
- Be transparent about data usage.
- Review your app’s functionality.
- Explore alternative APIs.
- Communicate clearly with users.
Infographic Placeholder: Visual representation of the changes in Facebook’s Graph API permissions.
FAQ
Q: Why does the /me/friends endpoint return limited data?
A: To enhance user privacy, Facebook restricted the data returned by this endpoint. It now primarily returns friends who have also authorized the app.
The landscape of social media APIs is constantly evolving. By understanding the reasons behind these changes and adapting your development strategies accordingly, you can continue to build engaging and privacy-respecting social experiences. Focus on providing value to your users while respecting their data privacy, and you’ll be well-positioned for success in this evolving digital world. Explore Facebook’s developer documentation and stay updated on the latest API changes to ensure your app remains compliant and functional. Check out these resources for further reading: Facebook for Developers, Facebook Privacy Policy Analysis, and EFF’s perspective on Facebook privacy.
- Stay updated on Facebook API changes.
- Prioritize user privacy in your app design.
Question & Answer :
I am trying to get my friend name and ids with Graph API v2.0, but data returns empty:
{ "data": [ ] }
When I was using v1.0, everything was OK with the following request:
FBRequest* friendsRequest = [FBRequest requestForMyFriends]; [friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection, NSDictionary* result, NSError *error) { NSArray* friends = [result objectForKey:@"data"]; NSLog(@"Found: %i friends", friends.count); for (NSDictionary<FBGraphUser>* friend in friends) { NSLog(@"I have a friend named %@ with id %@", friend.name, friend.id); } }];
But now I cannot get friends!
In v2.0 of the Graph API, calling /me/friends returns the person’s friends who also use the app.
In addition, in v2.0, you must request the user_friends permission from each user. user_friends is no longer included by default in every login. Each user must grant the user_friends permission in order to appear in the response to /me/friends. See the Facebook upgrade guide for more detailed information, or review the summary below.
If you want to access a list of non-app-using friends, there are two options:
- If you want to let your people tag their friends in stories that they publish to Facebook using your App, you can use the
/me/taggable_friendsAPI. Use of this endpoint requires review by Facebook and should only be used for the case where you’re rendering a list of friends in order to let the user tag them in a post. - If your App is a Game AND your Game supports Facebook Canvas, you can use the
/me/invitable_friendsendpoint in order to render a custom invite dialog, then pass the tokens returned by this API to the standard Requests Dialog.
In other cases, apps are no longer able to retrieve the full list of a user’s friends (only those friends who have specifically authorized your app using the user_friends permission). This has been confirmed by Facebook as ‘by design’.
For apps wanting allow people to invite friends to use an app, you can still use the Send Dialog on Web or the new Message Dialog on iOS and Android.
UPDATE: Facebook have published an FAQ on these changes here: https://developers.facebook.com/docs/apps/faq which explain all the options available to developers in order to invite friends etc.