发布到用户墙而不在线/登录 - 使用Graph API共享Facebook [英] Publishing To User's Wall Without Being Online/Logged-in - Facebook Sharing Using Graph API

查看:147
本文介绍了发布到用户墙而不在线/登录 - 使用Graph API共享Facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我是Facebook的新朋友。我想让用户使用他的uid登录,然后存储这些进一步的用途



主要目的是在用户墙上共享链接



下一次没有显示Facebook窗口我想通过ajax发布到他的墙上。



如何可能有任何帮助这将不胜感激!



编辑



我使用了给出的例子,然后尝试卷曲功能



得到这个错误

  HTTP / 1.1 403禁止
缓存控制:无存储
内容类型:文本/ javascript; charset = UTF-8
到期日:2000年1月1日星期六00:00:00 GMT
P3P:CP =Facebook没有P3P政策,了解为什么在这里:http://fb.me / p3p
Pragma:no-cache
WWW-Authenticate:OAuthFacebook Platform不足_(#200)
这个API调用需要一个有效的app_id。
设置Cookie:datr = g4JBTb4OsRZxBAztV7iIkpWg; expires = Sat,26-Jan-2013 14:34:43 GMT;
path = /;域= .facebook.com;日期:2011年1月27日14:34:43 GMT
内容长度:93

{error:{ type:OAuthException,message:(#200)
此API调用需要有效的app_id。}}

编辑有人可以找到有用的



FACEBOOK CONNECTION

  $ facebook_connect = array(
'appId'=>'你的APP_ID',
'secret'=>'你的钥匙',
'access_token'=>USER'S ACCESS TOKEN,
'cookie'=> true
);

发送到用户墙

  $ facebook-> api(/ PROFILE_ID / feed,post,array(
message=>Hi Friends Join ****,
name=>你被邀请加入****!,
link=>www。****。com,
description= >Great site,
picture=>http://www.****.com/logo.jpg,
caption=>加入** ***


解决方案

你开始学习Facebook Graph API如何工作。


  1. Facebook将 永远不会 分享用户密码!

  2. 如果您只需要给用户分享链接的可能性,那么只需使用 like plugin 。您还可以找到更多有趣的社交插件来使用在您的网站。

  3. 如果您使用类似的插件,它将不会打开任何弹出窗口,它会将链接直接发布到用户的墙上。

  4. 您可以随时使用 Feed对话

  5. 开始阅读 Facebook文档






现在要在用户墙上发帖(代表他) em>没有 他正在登录,您需要以下内容:


  1. app access_token

  2. publish_stream 权限,不需要的长期访问令牌:




使您的应用可以向用户的
流和用户的朋友的流发布内容,评论和喜好。这是一个超集
发布权限,还包括publish_actions。但是,
请注意,Facebook建议用户启动共享模式。
请阅读平台政策,以确保您了解如何
正确使用此权限。请注意,您不需要请求
publish_stream权限,以便使用Feed对话框,
请求对话框或发送对话框。


需要许可:

这可以通过多种方式完成:

使用登录插件

  < div class =fb-login-buttondata-show-faces =truedata-width =200data-scope =publish_streamdata-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(回复){
if(response.authResponse){
console.log('Welcome!Fetching your information ....');
FB.api('/ me',function响应){
console.log('很高兴见到你'+ response.name +'。');
FB.logout(function(response){
console.log('注销);
});
});
} else {
console.log('用户取消登录或没有完全授权。 $ b}
},{scope:'publish_stream'});

发布:

  $ USER_ID =XXXXXXXX; //连接一次到你的APP,而不需要登录在
$ args = array(
'message'=>'你好,从应用程序',
'link'=> ;'http://www.masteringapi.com/',
'caption'=>'访问MasteringAPI.com对于Facebook API教程!'
);
$ post_id = $ facebook-> api(/ $ USER_ID / feed,post,$ args);

注意:

虽然可以发布没有用户的存在永远记住Facebook建议用户启动的共享模型


Hi i'm new to facebook sharing. I want to make a user log in using his uid and then store these for further uses

The primary purpose is to share links in the user's wall

next time onwards without showing the facebook window i want to post in to his wall through ajax.

How is it possible any help regarding this will be appreciated!

EDIT

I used the example given and then tried curl function

got this error

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."}}

EDIT SO THAT SOMEONE MAY FIND USEFUL

FACEBOOK CONNECTION

$facebook_connect =  array(
   'appId'  => 'YOUR APP_ID',
   'secret' => 'YOUR SEC KEY',
          'access_token'=>"USER'S ACCESS TOKEN",
   'cookie' => true
 );

POST TO USER WALL

$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 *****"
)

解决方案

I suggest you start learning how Facebook Graph API works first.

  1. Facebook will NEVER share the user password with you!
  2. If you just need to give the user the possibility to share link, then just use the like plugin. You may also find more interesting social plugins to use in your website.
  3. If you use the like plugin, it won't open any popups and it would post the link directly to the user's wall.
  4. You could always use the Feed Dialog
  5. Start reading the Facebook Documentation


Now to post on the user's wall (on his behalf) without him being logged-in, you need the following:

  1. app access_token
  2. publish_stream permission, NO NEED for the long-lived access token:

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.

Require the permission:
This can be done in multiple of ways:
Using the 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 (Redirect to the OAuth Dialog):

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 through the FB.login method:

 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'});

Publishing:

$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);

Note:
While it's possible to post without the user's presence always remember Facebook recommends a user-initiated sharing model

这篇关于发布到用户墙而不在线/登录 - 使用Graph API共享Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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