Get invitable_friends Facebook API iOS - ios

I implement an app which need to get list invitable_friends from Facebook. I had researched how to get invitable_friends (have some question like that on stack overflow but I also cannot get any right way to fix it) and also tried but the result always null, I guess the reason is that :The invitable_friends list is only available for games with a Canvas implementation. But I don't know how to integrate Canvas or do somethings else to get the list invitable_friends(sorry, maybe it's a naive way to make a question but I'm not have any experience at this). please let me know the way to get this list(configuration my app on Facebook developer page or do anything).
Here is my code to get list after login success:
[FBRequestConnection startWithGraphPath:#"/me/invitable_friends"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
NSDictionary *result,
NSError *error
) {
/* handle the result */
NSLog(#"resurl");
}];

The Invitable Friends API is only available to apps classified as Games, which also have a Canvas presence. This API is not available in v1.0. It may be called by mobile games as long as they also have a Canvas presence.
Source: https://developers.facebook.com/docs/graph-api/reference/v2.2/user/invitable_friends
Meaning, it is ONLY possible for games, if your App is NOT a game you can forget about it. And you MUST have a Canvas implementation next to your mobile one. Meaning, you can´t just create a Canvas App that redirects (which would not be allowed), you would have to create a game that actually runs on Canvas too.
Detailed information about Canvas Apps can be found in the docs: https://developers.facebook.com/docs/games/canvas

After many research I found the solution. Into the Basic Setting field of Facebook Developer page
I need to add platform Website:Site URL:https://local.host:3000/ and Facebook Canvas:Secure Canvas URL:https://local.host:3000/. Of course this site is add for dummy app. When you want to public the app will need submit your app for review by Facebook, then you will need a real website.
You can see the answer of #Spundun Here. With those config, now I can get friends list by invitable-friends

Related

Why is facebook returning the friendlist 0 in iOS? How to retrieve fb friendlist and store it to parse?

Please see this previous discussion for building the context. How to retrieve Facebook friendlist and save it to parse?.
As that guy pointed out it's not possible any longer to retrieve friendlists, I tried retrieving it by using the older sdk. That sdk is working fine with my other app. But i still can't retrieve fb friendlist. I tried this method too, other than the two mentioned in the above stated question:
[FBRequestConnection startForMyFriendsWithCompletionHandler:
^(FBRequestConnection *connection, id<FBGraphUser> friends, NSError *error)
{}];
But it's still no bueno. Can someone please tell me what's wrong with it? How can i retrieve the fb friendlist and store it to parse?
Careful with "friendlist" and "friends", those are two different things. Although, i am pretty sure you don´t want to get the "friendlists", because those are just the lists without the friends in there.
Anyway, using an old SDK does not mean you can get all friends, the only way to still get all friends is by using an App created before end of April 2014 (with any SDK). And that solution only works until end of April 2015, of course.

How to integrate Facebook User's Newsfeed (or) Wall post in iOS App

I'm trying to integrate a custom view which shows a few post of the users Facebook news feed.
I'm looking for a good starting point. I don't want to use a UIWebView or something like this to grab the mobile site of Facebook instead I want to get data in JSON format or similar and display it in a custom fashion.
Can you give me any advice or links to tutorials how i can get the Facebook news feed data?
Edit: I want to update my requirements. I looked a bit into the Facebook Documentation and the SDK. There are some Sample Codes which are useful but I'm missing a straight forward tutorial or sample which does fetch the users newsfeed and displays it. This is why I made the bounty.
I will give the +100 Rep for somebody that creates a sample or tutorial which does get posts of the users newsfeed. Required would be: Get the name of the poster, message, timestamp and attached image. It would be nice if you also show them in a uiview but it is not required. If there is an existing framework feel free to link it.
I'm working myself on something similar and will publish it too. I think this could be tribute to the community.
I have created a sample starter project that gets the user's facebook newsfeed and displays it. It shows who did the post, the poster's profile picture, and when it was posted along with the message.
It is fairly rudimentary and could use some enhancement from other developers, i.e. endless scrolling, displaying any links, likes or recognizing URLs, etc.
https://github.com/AaronBratcher/UserFeed
I would integrate the Facebook API on my project, and then you can have access of many informations available on Facebook.
A good start point is read the documentation that you can find here:
https://developers.facebook.com
It's not hard to understand, but it has a lot of information!
Good luck.
At first, you need "read_stream" permission for your app.
Then read Facebook Query Language (FQL) Reference https://developers.facebook.com/docs/reference/fql/
To get the Newsfeed you can use the following code:
NSString *fqlString = #"SELECT * FROM stream WHERE filter_key IN (SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed') AND is_hidden=0 LIMIT <YOUR_LIMIT>";
[FBRequestConnection startWithGraphPath:#"/fql"
parameters: #{#"q": fqlString}
HTTPMethod:#"GET"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
<ANALYZE RESPONSE>
}];
Facebook API / SDK Request Wrapper
News feed post class
Simple UI to test the code
Getting Started:
facebook-sdk-posting-to-user-news-feed
Sample App
To my knowledge you cannot obtain News Feed data in your application. stream table shows only the posts that have appeared on your wall. To create a News Feed for a user Facebook uses his own private algorithm (it was Facebook Edgerank, but read that recently they had changed this algorithm to a new one).
To my point of view, to achieve your goal you can crawl data of all your friends and try to create an algorithm that will range these posts similar to the way it is done by Facebook.

How to send custom message to one friend using iOS facebook-graph-api?

I have a philosophy multiplayer question-answering app that allows players to play against each other answering questions about philosophy and ethics. For signup i allow facebook-login. I have a list where a player can invite his facebook friends to play. Its done with a request to the app-backend with all players friends, and return which have installed the app.
For those who dont yet have installed the app, i want to let the player invite them to install the app. I haven't found a way to do this with iOS graph API. Is it possible when a player taps a friend (i have the fbID), to send a message with some custom text and a link to download the app?
With the webdialogs method it does not seem to allow custom text send to one specific player. And that method opens a new window with friend selection. I don't need that as the user allready has selected a friend to invite. Is there a way to use FBWebDialogs to do this, or any other method in the Facebook iOS API?
[FBWebDialogs
presentRequestsDialogModallyWithSession:nil
message:#"Learn how to make your iOS apps social."
title:nil
parameters:nil
handler:nil]
The way to do this is to set up a simple XMPP server on your server and send it using their XMPP login which you can get with the following code snippet.
if (![FBSession.activeSession.permissions containsObject:#"xmpp_login"]){
[[FBSession activeSession] requestNewReadPermissions:#[#"xmpp_login"] completionHandler:^(FBSession * session, NSError * error){
if (!error){
[self functionThatCommunicatesWithServerAndSendsXMPPLoginInformation];
} else {
// handle error
}
}];
}
There are some nice frameworks that make XMPP really easy to implement on a simple level, such as SleekXMPP for python/django.
It's definitely a little work to do this, but probably much more effective. Just don't spam.
For more guides (although I think a little outdated):
Facebook chat framework for iphone sdk

Facebook iOS SDK - FWWebDialogs not rendering message

I'm using the Facebook SDK in an iOS app. I'm logging in fine, pulling in friends lists, etc.
I've added code to send a request:
[FBWebDialogs
presentRequestsDialogModallyWithSession:session
message:#"Message"
title:#"Title"
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
// view cleanup here
}];
The session is the FBSession stored in the class handling login. The params are suggestions, an array of friends to include. The issue described below occurs equally if params is nil (in which case the list shows all friends).
When I call the dialog, this is what appears:
Note that the "Message" text is missing, as is the entire Message block shown on the various Facebook documentation pages such as https://developers.facebook.com/docs/ios/ios-sdk-games/requests/.
I'm using Facebook SDK 3.7.1, the latest version as of this posting. The screenshot above is from the Simulator using a Facebook Test User account. The same issues occur on a device using a "real" Facebook account.
I'm seeing the same issue. It appears to be a very recent development, as previously the dialog did show the message preview. I also noticed that the dialog does show the message preview if I specify the 'to' parameter; the message preview is missing only if I omit the 'to' parameter so that the dialog shows all the user's friends. Unfortunately I don't have a solution, but I wanted to share these additional observations if it helps get closer to the solution.
Andrew
Apparently, this is "By Design"!! :(
https://developers.facebook.com/bugs/605575982818621

New iOS SDK 3.0, Posting to a user's wall without deprecated API

I'd like to know if there is a proper way to post a message to a user's wall with the new SDK.
From what I understand there is no way anymore to display a message preview with a dialog view to the user before posting.
I'd rather not using deprecated API. I followed the tutorial for login in with Facebook with the new SDK (importing the Framework etc). When it comes to post a message they ask to import the deprecated Facebook.h header (and its friends...) but it generates lot of compilation errors because some classes are named the same.
Do you people use the deprecated API?
Or do I have to create a custom view myself to display a preview to the user and then use the FBRequest method + requestWithGraphPath:parameters:HTTPMethod: to perform the post "in the background"?
The solution is simple. This worked for me:
We need not import the deprecated headers at all. By using only the latest facebook ios sdk 3.0 following is what you can do.
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:#"%#/feed",fbid]
parameters:params
HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection *connection, id result,NSError *error)
{
NSLog(#"error %# \n\n\nresult = %#",error,result);
}
fbid is the profile id of the user. You can give the friend's profile id in order to post on his wall.
In case you have to post on the user's own wall, you can either give the graph path as #"me/feed" or as stated above (by giving the fbid as the user's profile id)
Hope this helps.
As of Facebook SDK 3.2, it is now possible to display a native dialog with the new classes available in the SDK. Have a look to FBNativeDialogs, FBShareDialogParams and FBOpenGraphActionShareDialogParams.
I ran into the same problem and I couldn't find a way around importing the deprecated headers, like the tutorial says. After importing both the framework and Facebook.h with friends, clean your project to make sure the linker doesn't complain about the same file names.
The apprequests tutorial still explicitly says to import deprecated headers. So I don't think FB wants you to implement your own views. I would assume they had to release 3.0 and posting to wall and apprequests weren't finished, so they now have this hybrid 3.0/deprecated system until they finish the rest.

Resources