简体   繁体   English

在Facebook用户的朋友墙上发帖不起作用

[英]posting on facebook user's friend wall not working

im trying to accomplish an invitation from the facebook users to be posted on their friends wall or timeline. 我正在尝试完成来自Facebook用户的邀请,以便将其发布在他们的朋友墙或时间轴上。

This is what i have right now, a user selects his friend's to send the invitation through the multifriend selector, he sends the invitation and through a callback i get the ids of the invited friends. 这就是我现在所拥有的,用户选择他的朋友通过多朋友选择器发送邀请,他发送邀请,并通过回调获得被邀请朋友的ID。 This callback submits via ajax a form in which the idea is to post some info into this friends wall or timeline. 该回调通过ajax提交一个表单,该表单的想法是将一些信息发布到此好友墙或时间轴中。

However, the post into the user friend's wall is not working and i dont really know why. 但是,张贴到用户朋友墙的帖子无法正常工作,我真的不知道为什么。 This is what i got now: (the multifriend selector function is not shown, since its working right and the form is sucseffuly being submitted with the users ids) 这就是我现在得到的:(未显示多好友选择器功能,因为它的工作正确且表单已成功提交并带有用户ID)

$ids=$_POST['ids']; //comma separated string with friend's id
$userid=$_POST['userid'];//user id
$ids=explode(',', $ids);

$facebook = new Facebook(array(
  'appId'  => 'xxx',
  'secret' => 'xxx',
));

    for($i=0;$i<count($ids);$i++){
$attachment = array(
    'message' => 'Responde encuestas en Metrik y los dos ganamos 10 puntos!',
    'name' => 'Metrik Studios Social Surveys',
    'caption' => "responde encuestas y prueba productos novedosos a través de Metrik. Acumula kiloemtros Lanpass, recibe dinero, dona a fundaciones y mucho más.",
    'link' => $canvas_page.'?ref='.$userid,
    'description' => 'Metrik Studios',
    'picture' => 'http://metrikstudios.com/fbapp/logo.jpg',

);


$result = $facebook->api('/'.$ids[$i].'/feed/', 'post', $attachment);

}
?>

some other info: this is a canvas app on fb, the user granted the publish_stream permission to the app. 其他一些信息:这是fb上的canvas应用,用户向该应用授予了publish_stream权限。 WHen i change:$result = $facebook->api('/'.$ids[$i].'/feed/', 'post', $attachment); 如果我更改:$ result = $ facebook-> api('/'.$ ids [$ i]。'/ feed /','post',$ attachment); for: $result = $facebook->api('/me/feed/', 'post', $attachment); 为:$结果= $ facebook-> api('/ me / feed /','post',$ attachment); the post is made into the users feed 该帖子已纳入用户供稿

Thanks for the help! 谢谢您的帮助!

EDIT: Ok, I think the problem was that the app was in sandbox mode. 编辑:好的,我认为问题是该应用程序处于沙箱模式。 That way none can see the apps posts. 这样,没人能看到应用程序的帖子。

Actually i switched the sandbox mode off and like 20 posts where made into my friends feed. 实际上,我关闭了沙箱模式,并在我的好友供稿中添加了20个帖子。 Is this possible? 这可能吗? Hope that this helps if someone gets into this stupid situation, just as i did 希望有人像我一样陷入这种愚蠢的情况会有所帮助

Use this syntax for posting onto a person's Facebook Wall instead. 请使用此语法将其发布到一个人的Facebook墙上。

try {
    $newStatus = $facebook->api("/$USERID/feed", 'POST',
    array(
      'link' => "https://apps.facebook.com/XXXXXXXXX",
      'picture' => "https://XXXXXXXXX", //colour
      'name' => "XXXXXXXXX",
      'description' => "XXXXXXXXX",
      'access_token' => $access_token
     ));
     //echo '<pre>Post ID: ' . $newStatus['id'] . '</pre>';
} catch(FacebookApiException $e) {
        error_log($e->getType());
        error_log($e->getMessage());
        //echo '<textarea style="width: 300px; height: 200px;">' . $e->getMessage() . '</textarea>';
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM