2011-10-11 76 views
1

我目前正在开发一个Facebook应用程序在一个网站,需要在一些业务阶段发送通知给应用程序用户注册在它没有用户界面对话框。在阅读了一些博客之后,我得出结论,该选项仅适用于PHP API中的示例。应用程序的用户请求Facebook上的应用程序中的JavaScript

我上网了整个互联网,仍然一无所获,但这个例子:

http://developers.facebook.com/docs/channels/

有任何JavaScript API吗?

UPDATE:

那么,某种更多的阅读后,我发现FB.api可以处理图形对象的API,也是的REST API将被弃用,并且我得到了以下工作:

FB.api('/1175241653/apprequests', 'post', 
     { message: "This is a Good Request!!" }, 
     function (response) { 
      if (!response || response.error) { 
       alert('Error occured , Request Failed :(('); 
      } else { 
       alert('Request is sent successfully'); 
      } 
     }); 

然而,该ID号1175241653不一样,如果登录用户的id是不是该ID工作。

因此,这需要与facebook用来检索登录到应用程序的用户的ID相同的功能。有没有办法做到这一点?现在

回答

1

,我得到了一切手段这方面的工作,我想与那些谁可以处理:))

让说,1日为从乌尔应用到任何的做一个单一的应用程序请求共享Facebook的注册您的应用程序的用户会是这样的:

var data = 
    { 
     message: "Hey there, something good happened over here !", 
     access_token: "AAADdf39DLxgBANEwZA9ZCfZCSbtdfcZBtstWMMsW5JiZBjVW2Ucx234sedhHSZCm8aEABzvhWPBNWi1bTKwZBq0EcgZD" 
    } 


FB.api('/68751034/apprequests', 
     'post', 
     data, 
     function (response) { 
      console.log(response); 
      if (!response || response.error) { 

      } else { 

      } 
     }); 

access_token应提供的认证从申请到注册用户的要求。

http://developers.facebook.com/docs/authentication/

另外,如果你想批量请求发送给一组用户的一个请求:

如果你不知道的访问令牌,你可以在Facebook网站读到它了打电话,有一个支持页面由Facebook网站有关太:

http://developers.facebook.com/docs/reference/api/batch/

和这里的我的意思样本:

var _batch = []; 

for (var i = 0; i < _socialids.length; i++) { 
    _batch.push({ 
     method: 'post', 
     relative_url: _socialids[i] + '/apprequests/?access_token=' + _accessTokens[i], 
     body: "message= This is a request sent to many users" }); 
    } 
    if (_batch.length > 0) { 
     FB.api('/', 'POST', { batch: _batch }, function (res) { 
      // Do whatever when the batch request is sent 
     }); 
    } 
相关问题