问题描述
使用图形api publish_stream权限:以及offline_access权限:
Using graph api publish_stream permission: together with offline_access permission:
此处和.但是由于某些原因,发生以下两种情况之一:
As described here and here. However for some reason one of the following two things are happening:
我正在尝试登录到当前登录的用户的操作(例如,告诉用户#1用户#2访问了Farmville的农场,但告诉用户#1),将其发布到当前尚未登录的Facebook用户尚未登录,而用户#2则未登录.他们不一定是朋友.)
I am trying to post to a facebook user which is not currently logged in, following an action of a user which is curently logged in (e.g. telling user #1 that user #2 visited their farm in farmville, but user #1 is not logged in, while user #2 is. And they are not necessarily friends).
当我使用以下代码尝试此操作时,当用户#1和#2不是朋友(第一个问题)时,并没有创建该帖子;而当他们是朋友时,正在创建该帖子,但看起来像是用户#2正在将其发布在用户#1的墙上(第二个问题-这不是我要尝试的操作,我希望它是匿名的).请参阅我使用的第一个代码:
When I tried this using the following code, the post was not created when users #1 and #2 were not friends (first problem), and when they were friends, the post was being created, but seemed like user #2 was posting it on user #1's wall (second problem - this is NOT what I am trying to do, I want it to be anonymous).See the first code I used:
$post_id = $facebook->api('/' . $user1_id . '/feed/', 'post', array(
'message' => 'Someone just visited your farm',
'link' => 'http://example.com',
'picture' => 'http://example.com/img/picture.jpg',
'caption' => 'Visit farms!'
));
因此,我尝试使用用户#1的访问令牌,该令牌是他登录时提供给我的,即使该用户处于离线状态(即使没有offline_access权限,该应用程序也应该能够在他们的墙上发帖-请参见此处 facebook的文档:您可以发布...而无需offline_access"无论如何,当我将access_token作为参数添加到数组中时(请参见下面的代码),根本不会创建任何帖子:
So I tried to use the access token of user #1, which he gave me when he was logged in, and the application is supposed to be able to post on their wall even when they are offline (even without offline_access permission - see here facebook's documentation: "you can publish... without requiring offline_access". At any rate, when I am adding the access_token to the array as a parameter (see the code below), no post is being created at all:
$post_id = $facebook->api('/' . $user1_id . '/feed/', 'post', array(
'access_token' => $user1_access_token,
'message' => 'Someone just visited your farm',
'link' => 'http://example.com',
'picture' => 'http://example.com/img/picture.jpg',
'caption' => 'Visit farms!'
));
我该怎么办?
获得收益,我只是试图将其发布到未登录的用户墙上,但是谁给了我publish_stream权限,来自该应用程序的帖子,而不是其他任何用户,并告诉该用户某人(匿名)已经访问过"他们的农场"(或创建了一些与其相关的操作).
gain, I am simply trying to publish to user's wall that is NOT logged in, but who gave me the publish_stream permission, a post from the application, not any other user, telling this user that someone (anonymously) has "visited their farm" (or created some action associated with them).
谢谢大家.
推荐答案
这只是一个推荐&我不确定这是否是答案销毁所有会话(或以专用模式使用浏览器-对于Firefox)&然后像这样访问发件人页面
this is just a recommend & i'm not sure this be the answer Destroy all of the sessions (or use your browser in private mode -for Firefox )& then visit sender page Like this
example.com/postfarm.php
example.com/postfarm.php
也许当您正常访问该页面时,该应用会获取您的access_token&尝试以您的身份发布
maybe when you visit the page normally the app gets your access_token & tries to post as you
PS:更好的方式
使用此代码&您不再需要销毁会话
use this code & you dont need to destroy sessions anymore
include_once ('src/facebook.php');/// include sdk
////// config The sdk
@ $facebook = new Facebook(array(
'appId' => 'XXXXXXX',
'secret' => 'XXXXXXXXXXXXXX',
));
$facebook->destroySession();
try{
$post=$facebook->api('USER_ID/feed/','POST',array(
'message' => '$message',
'link'=>'http://apps.facebook.com/xxxxxxx/link.php?link=',
'picture'=> 'XXXXXXXXXX',
'name'=>'XXXXXX',
'description'=>'yes',
));
}
catch(FacebookApiException $e) {
echo $e->getType();
echo '<br />';
echo $e->getMessage();
}
这篇关于从应用程序发布流-对于非登录用户,使用Graph API,php SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!