Can Facebook's Requests Dialog work as a displ

2020-07-18 03:59发布

问题:

All of Facebook's Dialogs examples show a page to redirect the user to in the form http:// www.facebook.com/dialog/xxx?yyy... EXCEPT the Requests Dialog, which shows examples using FB.UI() in the JavaScript SDK.

http://developers.facebook.com/docs/reference/dialogs/requests/

My question, not addressed anywhere on the Facebook documentation, is can the requests dislog be accessed by directing the browser to http://www.facebook.com/dialog/apprequests?...

I've been trying for hours, but I keep getting "Sorry, an error occurred." Am I doing it wrong or can it not be done?

回答1:

i am able to solve it

you need to use URL like

http://www.facebook.com/dialog/apprequests?app_id=APP_ID&redirect_uri=URL_GIVEN_IN_APP/&message=abc

Its is working fine for me. Hope it helps.



回答2:

You cannot make a request dialog behave as page directly, but you can use XFBML and fb:request-form into a, let's say, invite.php page into your app to create a request invitation form.

http://developers.facebook.com/docs/reference/javascript/fb.xfbml.parse/ http://developers.facebook.com/docs/reference/fbml/serverFbml/



回答3:

I tried to debug this a lot.

The final code which seems to have worked once was

<iframe src="https://www.facebook.com/dialog/apprequests?access_token=xxxx&api_key=xxxx&app_id=xxxx&display=iframe&frictionless=false&locale=en_US&message=abc&next=xxxx" frameborder="0">

I got this to work on one of the browsers, but when i try it in the other browser i consecutively keep getting the error below.

API Error Code: 110 API Error Description: Invalid user id Error Message: Missing user cookie (to validate session user)

What's the best way to set the user cookie? Facebook Connect Maybe? I will maybe use this code somewhere inside a Facebook App and check if it works. I think its just the cookie issue now.. i also tried supplying &user_id manually but it didn't work.

This definitely won't work with http IMO, it has to be https.



回答4:

http://developers.facebook.com/docs/reference/javascript/FB.ui/

You can specify a display parameter as seen in "Parameters" section.

FB.ui({
   method: 'apprequests',
   display: 'iframe',
   message: 'Your message',
   title: 'Your title'
}, function(response) {
   alert(response.request_ids);
});


回答5:

I believe you are right. If you combine the info from http://developers.facebook.com/docs/reference/dialogs/requests/ and http://developers.facebook.com/docs/reference/dialogs/, your url should be working... I tried it too but I also get error message...



回答6:

As Gokhan Ozturk said, You can specify ( display: 'iframe' ) for Apprequests.

For this to work you will have to provide an access token for the user:

FB.ui({ 
  method: 'apprequests',
  display: 'iframe',
  access_token: Users Access Token Here,
  title: 'Sample Title',
  message: 'Sample Message',
  data: 'some data here',
  filters: ['all'],
},
function(response) {
  if (response && response.request_ids) {
    alert('Request was sent');
  } else {
    alert('Request was not sent');
  }
});

You will also want to FB.init() through the JSDK, but you can do this without using it for controlling user access tokens and authentication,

FB.init({ 
  appId: 'Application Id',
  status: false,
  cookie: false,
  xfbml: false 
});

This has worked for me, where i use php to authenticate, while still needing access to the fb.ui functionality from the javascript sdk.

the display: 'iframe' - should work for all the dialog methods 'friends' , 'feed', 'send' etc.