php – 在没有在线/登录的情况下发布到用户的墙 – 使用Graph API进行Facebook共享

嗨,我是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连接

$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的工作原理.

> Facebook绝不会与您分享用户密码!
>如果您只需要给用户分享链接的可能性,那么只需使用like plugin.您还可以在您的网站上找到更有趣的social plugins.
>如果您使用类似的插件,它将不会打开任何弹出窗口,它会将链接直接发布到用户的墙上.
>您可以随时使用Feed Dialog
>开始阅读Facebook Documentation

现在要在用户的墙上(代表他)发布而不登录,您需要以下内容

> app access_token
> publish_stream权限,不需要长期访问令牌:

Enables your app to post content,comments,and likes to a user’s
stream and to the streams of the user’s friends. This is a superset
publishing permission which also includes publish_actions. However,
please note that Facebook recommends a user-initiated sharing model.
Please read the Platform Policies to ensure you understand how to
properly use this permission. Note,you do not need to request the
publish_stream permission in order to use the Feed Dialog,the
Requests Dialog or the Send Dialog.

需要许可:
这可以通过多种方式完成:
使用Login Plugin

<div class="fb-login-button" data-show-faces="true" data-width="200" data-scope="publish_stream" data-max-rows="1"></div>

Server-side login(重定向到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",$args);

注意:虽然可以在没有用户存在的情况下发布,但始终记得Facebook推荐用户启动的共享模型

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...