2010-08-01 90 views
1

我一直在疯狂和不能弄清楚如何为我的应用程序创建一个脚本,以允许用户选择一个朋友并通过我的应用程序向他们发送通知或发布在他们的墙上。在墙上发送通知或张贴

我只需要告知他们的朋友,他们一直面临的挑战是播放Flash游戏,只是一个简单的文本的链接,我不需要任何幻想:d

这里是我的尝试,它不工作:(不知道为什么

$message = 'Watch this video!'; 
$attachment = array('name' => 'ninja cat', 'href' => 'http://www.youtube.com/watch?v=muLIPWjks_M', 'caption' => '{*actor*} uploaded a video to www.youtube.com', 'description' => 'a sneaky cat', 'properties' => array('category' => array('text' => 'pets', 'href' => 'http://www.youtube.com/browse?s=mp&t=t&c=15'), 'ratings' => '5 stars'), 'media' => array(array('type' => 'flash', 'swfsrc' => 'http://www.youtube.com/v/fzzjgBAaWZw&hl=en&fs=1', 'imgsrc' => 'http://img.youtube.com/vi/muLIPWjks_M/default.jpg?h=100&w=200&sigh=__wsYqEz4uZUOvBIb8g-wljxpfc3Q=', 'width' => '100', 'height' => '80', 'expanded_width' => '160', 'expanded_height' => '120'))); 
$action_links = array(array('text' => 'Upload a video', 'href' => 'http://www.youtube.com/my_videos_upload')); 
$target_id = $user; 
$facebook->api_client->stream_publish($message, $attachment, $action_links, $target_id); 

更新: appinclude.php

$facebook->redirect('https://graph.facebook.com/oauth/authorize?client_id=132611566776827&redirect_uri=https://apps.facebook.com/gamesorbiter/&scope=publish_stream'); 

错误或者我得到:

{ 
    "error": { 
     "type": "OAuthException", 
     "message": "Invalid redirect_uri: The Facebook Connect cross-domain receiver URL (https://apps.facebook.com/gamesorbiter/) must be in the same domain or be in a subdomain of an application's base domain (gamesorbiter.com). You can configure the base domain in the application's settings." 
    } 
} 

如果没有额外的 “S”(HTTP)我得到这个错误:

Firefox has detected that the server is redirecting the request for this address in a way that will never complete. 

请,如果你可以发布一个例子。 我也需要扩展许可来做到这一点,或者如果用户发送消息,我不需要吗?

谢谢

回答

0

Also do i need extended permission to do that or if the user sends the message i dont that ?

是的,你需要从用户offline_access and publish_stream扩展权限。

更新:

在你appinclude.php文件,把这样的代码:

$facebook = new Facebook($appapikey, $appsecret); 
$user = $facebook->require_login(); 

$facebook->redirect('https://graph.facebook.com/oauth/authorize? 
client_id=[YOUR APP ID]& 
redirect_uri=[YOUR APP URL]& 
scope=publish_stream, offline_access'); 

更换[YOUR APP ID]与应用程序ID,您可以从应用程序设置看到您所创建的网站在Facebook开发人员部分。还请将[YOUR APP URL]替换为您的应用网址。

+0

我的代码在我的appinclude.php [code] $ facebook = new Facebook($ appapikey,$ appsecret); $ user = $ facebook-> require_login($ required_permissions ='publish_stream'); [/ code] 但是,当我从我的配置文件中删除应用程序,并再次访问它,我得到相同的旧的基本权限对话框。为什么没有申请publish_stream权限? – Krasi 2010-08-01 08:01:33

+0

@Krasi:看到这个获得你想要的任何权限:http://developers.facebook.com/docs/authentication/ – Sarfraz 2010-08-01 08:04:58

+0

哦,我申请了我的应用程序的扩展许可,并希望Facebook会批准我的申请。 我没有办法让用户通过我的应用程序向另一个用户发送消息,基本上绕过权限问题? – Krasi 2010-08-01 08:10:50