嗨,我是Facebook分享的新手。我想让用户使用其uid登录,然后将其存储以备将来使用
主要目的是在用户墙上共享链接
下次再不显示Facebook窗口,我想通过Ajax发布到他的墙上。
对此有什么帮助将不胜感激!
编辑
我使用了给出的示例,然后尝试了curl函数
得到这个错误
HTTP/1.1 403 Forbidden Cache-Control: no-store Content-Type: text/javascript; charset=UTF-8 Expires: Sat, 01 Jan 2000 00:00:00 GMT P3P: CP="Facebook does not have a P3P policy. Learn why here: http://fb.me/p3p" Pragma: no-cache WWW-Authenticate: OAuth "Facebook Platform" "insufficient_scope" "(#200) This API call requires a valid app_id." Set-Cookie: datr=g4JBTb4OsRZxBAztV7iIkpWg; expires=Sat, 26-Jan-2013 14:34:43 GMT; path=/; domain=.facebook.com; httponly X-Cnection: close Date: Thu, 27 Jan 2011 14:34:43 GMT Content-Length: 93 {"error":{"type":"OAuthException","message":"(#200) This API call requires a valid app_id."}}
进行编辑以使有人可以找到有用的地方
脸书连接
$facebook_connect = array( 'appId' => 'YOUR APP_ID', 'secret' => 'YOUR SEC KEY', 'access_token'=>"USER'S ACCESS TOKEN", 'cookie' => true );
发布到用户墙
$facebook->api("/PROFILE_ID/feed", "post", array( "message"=>"Hi Friends Join ****", "name"=>"You're invited to join ****!", "link"=>"www.****.com", "description"=>"Great site", "picture"=>"http://www.****.com/logo.jpg", "caption"=>"Join *****" )
我建议您首先学习Facebook Graph API的工作方式。
现在要在 不 登录的 情况下 (代表他)张贴在用户的墙上,您需要执行以下操作:
access_token
publish_stream
使您的应用能够向用户流和用户朋友流发布内容,评论和喜欢的内容。这是一个超集发布许可,其中还包括publish_actions。但是,请注意,Facebook建议使用用户启动的共享模型。请阅读平台政策,以确保您了解如何正确使用此权限。注意,您不需要使用feed对话框,Requests对话框或Send对话框就可以请求publish_stream权限。
需要许可: 可以通过多种方式完成: 使用登录插件:
<div class="fb-login-button" data-show-faces="true" data-width="200" data-scope="publish_stream" data-max-rows="1"></div>
服务器端登录(重定向到OAuth对话框):
https://www.facebook.com/dialog/oauth? client_id=YOUR_APP_ID &redirect_uri=YOUR_URL &scope=publish_stream &state=SOME_ARBITRARY_BUT_UNIQUE_STRING
PHP-SDK:
$loginUrl = $facebook->getLoginUrl(array("scope"=>"publish_stream"));
JS- SDK通过FB.login方法:
FB.login(function(response) { if (response.authResponse) { console.log('Welcome! Fetching your information.... '); FB.api('/me', function(response) { console.log('Good to see you, ' + response.name + '.'); FB.logout(function(response) { console.log('Logged out.'); }); }); } else { console.log('User cancelled login or did not fully authorize.'); } }, {scope: 'publish_stream'});
出版:
$USER_ID = "XXXXXXXX"; // Connected once to your APP and not necessary logged-in at the moment $args = array( 'message' => 'Hello from app', 'link' => 'http://www.masteringapi.com/', 'caption' => 'Visit MasteringAPI.com For Facebook API Tutorials!' ); $post_id = $facebook->api("/$USER_ID/feed", "post", $args);
注意: 尽管可以在用户不在场的情况下进行发布,但请务必记住,Facebook建议用户启动共享模型