如何与Facebook setUrlHandler工作?工作、Facebook、setUrlHandler

由网友(误入人间)分享简介:即时通讯使用的应用程序(http://apps.facebook.com/greetingz),这是一个使用,我可以发送一个请求,并接收器接收通知,但是当接收器点击通知AJAX部分IM的去直接画布页面apps.facebook.com/greetingz,其实我想表现出不同的页面..请在此帮助!Im using an...

即时通讯使用的应用程序(http://apps.facebook.com/greetingz),这是一个使用,我可以发送一个请求,并接收器接收通知,但是当接收器点击通知AJAX部分IM的去直接画布页面apps.facebook.com/greetingz,其实我想表现出不同的页面..请在此帮助!

Im using an App("http://apps.facebook.com/greetingz") and this is the ajax part im using, I can send a request and also receiver receiving a notification but when receiver click on the notification its goes to directly canvas page "apps.facebook.com/greetingz" , actually i wanna show a different page.. please help on this !!

    <?php 
         $app_id = "127736900693315";

         $canvas_page = "http://apps.facebook.com/greetingz";

         $message = $_POST['varx'];


         $requests_url = "https://www.facebook.com/dialog/apprequests?app_id=" 
                . $app_id . "&redirect_uri=" . urlencode($canvas_page)
                . "&message=" . $message;

         if (empty($_REQUEST["request_ids"])) {
            echo("<script> top.location.href='" . $requests_url . "'</script>");


         } else {
           // echo "Request Ids: ";
            //print_r($_REQUEST["request_ids"]);
            echo $message;
         }
?>

我如何使用低于code到该应用程序

how can i use below code to this App

 function onUrl(data) {
 if (data.path.indexOf("games.achieves") != -1) {
     console.log('I will process some achievement now.');
 } else if (data.path.indexOf("request_ids") != -1) {
     console.log('I will process some request now.');
 } else {
     // default behaviour
     window.location = data.path;
 }

}

FB.Canvas.setUrlHandler(onUrl);

FB.Canvas.setUrlHandler(onUrl);

推荐答案

您必须与FB API初始化后的一些延迟设置处理函数。

You have to set the handler function with some delay after initialization of the FB api.

FB.init(params);
setTimeout(function() { FB.Canvas.setUrlHandler(onUrl) }, 5000);

使用这种方式,我得到了这个功能的工作。

Using this way I got this feature working.

阅读全文

相关推荐

最新文章