使用Graph Api发送Facebook App Request / Invite [英] Send Facebook App Request/Invite using Graph Api

查看:239
本文介绍了使用Graph Api发送Facebook App Request / Invite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,将使用图形API获取你的朋友列表

  function getFriendsList(){

$ response = $ this-> api('/ me / friends');
return $ response;

}

这将返回朋友的ID和名称。使用图表api



然后我在joomla模块中执行此代码:

  $ fbClient = JFBConnectFacebookLibrary :: getInstance(); 
$ fbUserId = $ fbClient-> getUserId(TRUE);

//如果FB用户
if($ fbUserId){

$ f_list = $ fbClient-> getFriendsList();

在我得到数组后,我显示了firends图片


$ b $ ($ i = 0; $ i $($ friend); $ i ++)
($ i $ 0)
{

echo'< img src =http://graph.facebook.com/'.$friend[$i]['id'].'/picture>< br />';
}
}

}

创建我的朋友的个人资料照片。



我的问题是如何创建一个onlick,以便当我点击照片,我可以发送个人的Facebook应用程序请求。

解决方案

发送Facebook应用程序请求无法通过图形API。您可以使用应用请求javascript对话框发送请求,但您只需要指定文档中详细介绍的to属性中的用户ID。



示例功能:

 < script> 
FB.init({appId:'** appId **',status:true,cookie:true,xfbml:true});

函数sendRequest(to){
FB.ui({method:'apprequests',to:to,message:'你应该了解更多关于这个真棒网站'',data:'跟踪用户的信息'});
返回false;
}
< / script>

然后只需将每个图像的onclick连接到类似 onclick =return sendRequest('** friendId **');


I have the following code that would get ur friends list using graph api

function getFriendsList(){

    $response = $this->api('/me/friends'); 
     return $response;

    }

This returns friends id and name. using graph api

I then execute this code in my joomla module:

$fbClient = JFBConnectFacebookLibrary::getInstance();
$fbUserId = $fbClient->getUserId(TRUE);   

//If FB User
if($fbUserId){

$f_list = $fbClient->getFriendsList();

after i get the array i display the firends picture

foreach ($f_list as $friend) {
    for($i = 0; $i < count($friend); $i++)
        { 

        echo '<img src="http://graph.facebook.com/'.$friend[$i]['id'].'/picture"><br/>';
        }
   }

}

This would create the profile photos of my friends.

My question is how do i create an onlick even so that when i click the photo i can send an individual facebook app request. ???

解决方案

Sending Facebook app requests are not available via the graph api. You can use the app requests javascript dialog to send the request though, you would just need to specify the user's id in the "to" property as detailed in the documentation.

Sample function:

<script>
  FB.init({ appId: '**appId**', status: true, cookie: true, xfbml : true });

  function sendRequest(to) {
    FB.ui({method: 'apprequests', to: to, message: 'You should learn more about this awesome site.', data: 'tracking information for the user'});
    return false;
  }
</script>

Then just wire an onclick for each image to something like onclick="return sendRequest('**friendId**');"

这篇关于使用Graph Api发送Facebook App Request / Invite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆