简体   繁体   中英

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.

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. This callback submits via ajax a form in which the idea is to post some info into this friends wall or timeline.

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)

$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. WHen i change:$result = $facebook->api('/'.$ids[$i].'/feed/', 'post', $attachment); for: $result = $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. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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