How to Send App request to facebook friends through facebook iOS sdk? - facebook-graph-api

I am using facebook sdk for my my iOS facebook application. I want to send app request to multiple users. I am using following method for that purpose.
NSArray* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
#"Get Started",#"name",#"http://www.facebook.com/apps/application.php?id=135775646522275/",#"link", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Check out this awesome app I am using.",#"message",
#"Check this out", #"notification_text",
#"http://www.facebook.com/apps/application.php?id=135775646522275/",#"link",
appImage,#"picture",
actionLinksStr, #"actions",
nil];
[facebook dialog:#"apprequests"
andParams:params
andDelegate:self];
The problem is, I after calling this method, app request web view appears and app request is submitted successfully. But only app_request count on friends wall increases, Neither he gets any notification for app request, nor he can see the app request.
What can be the problem, is there any other alternative way to send app request from iOS facebook app ?

Here is the fix:
Go to http://developers.facebook.com.
Edit your app settings.
Check 'App on Facebook' and 'Native iOS App'.
Enter web-site URL of your app (if you have) as the Canvas URL (Secure Canvas URL can be the same).
Enter iOS Bundle ID and iPhone/iPad App Store ID (You can find this info on your App page at iTunes connect).
Canvas URL is used to redirect your friend if he reviews the request from Web-site
iOS Bundle ID and iPhone/iPad App Store ID are used to redirect your friend to App Store if he reviews the request from Native iOS App.

Related

How can I post content to an app users page, linking to their website, from an app running on my website?

I am creating an app for a client that allows their clients to schedule posts and post to facebook from the app.
Clients log into my-domain and the app requests permissions to post to their pages. I am fine with getting a list of pages from facebook and requesting the pages_read_engagement and pages_manage_posts permissions.
My app needs to allow users to select an image (hosted on my-domain) and post that with a link that points at their-domain, along with the post content. Here is an example of an api call I am making using the Javascript SDK (from my app at my-domain):
FB.api('/' + page_id + '/feed', 'POST', {
message: post.content,
link: user.website,
picture: image.url,
access_token: page_access_token
}, () => {})
I get back an error:
(#100) Only owners of the URL have the ability to specify the picture, name, thumbnail or description params.
I have had a read through the domain verification docs but I don't understand what I need to do next. Do all of my users have to verify their own domain via DNS verification? Is there a way for me to allow users to post to their own pages, linking to their websites, from my app, without them having to do anything technical? Am I missing something?

notification from app request Facebook not received

Im making an application on Phonegap, and therefore using javascript. I have added the facebook plugin, and everything seems to work fine. The user can log in and make app requests to friends using the FB.ui:
FB.ui({method: 'apprequests',
message: 'Try this application, and get ready to Guess This Sound!'
}, requestCallback);
The dialog pop up, and when I send an invitation my requestCallback method return OK
function requestCallback(response){
alert("response " + response);
}
However, my friends do not receive any notification about the request. My application is no longer i sandbox mode, and I can't figure out whats the problem is. Since Im using phonegap, I have added ios and android platform on facebook, and I guess no canvas URL is needed.
UPDATE
Some users do now receive the notifications from the application, but not everyone.However, when my friend clicks on the notification he receive this message: "The requested page can not be viewed right now. It could be temporary unavailable." Is it because my application is not available on google play and app store for the moment?
You have to Add app in your developer account
facebook -> Apps -> "You app" -> Setting -> add platform -> App on Facebook -> Add any URl
Now you will get app request notification
The problem was due to wrong set up in facebook developer API. The error still remains, but is because the app is not released yet. To see the solution to this, see:
Facebook invite request error android

How to implement authentication for mobile Django client based upon JqueryMobile, AngularJs, PhoneGap

I'm trying to create a one-site mobile app using AngularJS and jquerymobile, deploying it as a "native" app using PhoneGap. The one-page navigation is build up similar to this jsfiddle, using jquerymobiles data-role="page" for in-page navigation.
<div id="page-1" data-role="page">..some content for page one</div>
<div id="page-2" data-role="page">..some content for page two</div>
The app should provide a login screen to the user. After a successful login the user is able to access the rest of the app.
The app is the mobile companion for a Django driven web portal. Regarding the web portal things are straight forward. I log the user in and check on the server whether the user is allowed to access a certain view.
For the mobile client I'm a bit lost. Do I have to implement some kind of tokken authentication? How can I get the csrf token into my angularjs scripts to do some ajax calls (GET and POST) to my backend? How can I refresh page-1 independent from page-2? I would look for some hints where to start and what to take care off.
We’ve the following :
[Client {JQM}/{PhoneGap}] ← REST → [Web-Server]—[Django/Social-Auth]
When DeviceReady and JQM are fully initialized, client issues GET to the server to test if it is already authenticated.
If yes, go to starting page; otherwise, go to log-in page. Then it is just normal authentication flow. Once it is authenticated, route to starting page.
Hope this help.
We did set cors in the client
$( document ).bind( "mobileinit", function() {
$.support.cors = true;
$.mobile.allowCrossDomainPages = true;
}

Canvas app not being sent signed_request POST parameter

I understood from Facebook's tutorial that someone clicks on your Facebook app and is brought to your app page: http://apps.facebook.com/example_app
Then Facebook opens an iframe with your canvas URL and does a POST with the signed_request parameter. That parameter has all the info you need, check it if the user has accepted your application. If not, redirect to the OAuth 2 flow. If they have, then the signed_request will contain their user_id.
Unfortunately, I'm not passed any signed_request parameter when I click on my facebook app! This is what I'm passed in the POST request body:
fb_sig_in_iframe=1&fb_sig_locale=en_US&fb_sig_in_new_facebook=1&fb_sig_time=1316465522.5989&fb_sig_added=1&fb_sig_profile_update_time=1280164553&fb_sig_expires=1316469600&fb_sig_user=111111111&fb_sig_session_key=&fb_sig_ss=222222222222222&fb_sig_cookie_sig=333333333333&fb_sig_ext_perms=email&fb_sig_country=us&fb_sig_api_key=44444444444444&fb_sig_app_id=555555555555&fb_sig=66666666666
Is it the above or signed_request? I'm confused... how can I get the access_token of the user and his user_id?
This won't be enabled for all (especially older) apps by default, there's a setting you need to enable in the App's Advanced settings, under 'Migrations' to enable signed_request for canvas apps

User accepts Facebook request then autologins to my website

I have an invite friends button, that creates a facebook request to the friends you select through facebook's javascript UI mechanism. The invitees can then click "Accept" and they'll be redirected to my facebook canvas app.
From there I want them to be redirected to my website but automatically logged in with their facebook credentials as if they clicked my Facebook Connect button and logged in that way. How can I do this? I guess somehow the same cookie FB Connect creates will need to be created? My website will need to be given some kind of access_token like FB Connect returns so I can verify who the user is on my system (or create a new one).
Or is this not possible and the user will have to be simply redirected back to my website and then login through Facebook Connect even though they're already "logged in" to my facebook canvas app?
Once the user gets redirected to your Canvas App (iframe) you are in control!
So let's assume the following:
The friend clicks "Accept" and get redirected to Your Canvas App
You receive a signed_request, and check if a user_id presents (i.e he is already a website user)
if yes then just set your own login sessions (or whatever mechanism you use) and redirect else
Follow the standard authentication flow (whether it's client side or server side)
If the user clicks cancel then just redirect
if he authorizes your app then register user (insert to DB) and follow step #3