How can I redirect to my app page after accepted a app request sent from our app?

和自甴很熟 提交于 2019-12-08 07:41:03

问题


I have a issue for facebook apprequests (oauth2, graph)

I sent a app request to my friend B. B logged into facebook and found our request in the app list. B clicked the accept button

B redirected to the facebook canvas page. I want to rediect to our app, not facebook's canvas, is this doable?

thanks


回答1:


you can put a url in the data param

see here http://developers.facebook.com/docs/reference/dialogs/requests/ under properties at bottom.

data Optional, additional data you may pass for tracking. This will be stored as part of the request objects created.

This will get passed back to you and you can use javascript to location.href to the url in the data.

----------Here is a sample i have used in the past

    var thisimg = 'AN_IMG';
    var thisurl = 'A_URL';  
    window.sendrequest = function(){
             FB.ui({ method: 'apprequests', 
             title: 'A request.',
        message: 'Rate Me! Request from: ' +thisname+' ',
        data: ''+thisimg+' '+thisurl+' ',
        filters: ['all'],
        });
        }

---------- Sample from Facebook with data param added.

        var thisimg = 'AN_IMG';
        var thisurl = 'A_URL';
  function sendRequestToManyRecipients() {
    FB.ui({method: 'apprequests',
      message: 'My Great Request',
      data: ''+thisimg+' '+thisurl+' ',
    }, requestCallback);
  }

  function requestCallback(response) {
    // Handle callback here
  }

upon callback you can do a window.top.location.href=''; with the url you passed in data.

NOTE: The default redirect for a request is the canvas, this cannot be changed. After user lands on your canvas you will read the data param from the request and redirect them to your external app.

"i do not see any other way to do this, since requests2.0 does not include option for a redirect uri."




回答2:


As you have already included Facebook javascript SDK in your App and you have writen this code for inviting friend for your App in a script

FB.ui({ method: 'apprequests', redirect_uri: 'APP URL', message: 'My Message' });

This will redirect to App URL without redirecting to Facebook canvas URL.So this will not work even if you use data parameter such as

FB.ui({ method: 'apprequests', data: 'APP URL', message: 'My Message' });

Write this code at your App landing page i.e. in index.php

$requestid=$_GET[request_ids];
if(!empty($requestid)) {
    echo "<script> window.top.location.href='APP URL'; </script>";
}



回答3:


This is an old question, but now there is a simpler solution.

In the Facebook app settings under "Facebook Canvas" there is a field titled "Mobile Site URL". When a user tries to open your canvas app from a mobile device (s)he will be redirected to that URL.

That URL should point to a page from which you should redirect to the App Store or Play Store (or coming soon page) based on the browser user agent.



来源:https://stackoverflow.com/questions/7639264/how-can-i-redirect-to-my-app-page-after-accepted-a-app-request-sent-from-our-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!