Post to a Facebook user's wall with cURL PHP

后端 未结 3 918
温柔的废话
温柔的废话 2020-11-29 02:15

I\'m storing facebook userid\'s and access tokens. Can i post to a selected user\'s wall with this information? The following code is found here: http://developers.facebook.

3条回答
  •  时光取名叫无心
    2020-11-29 03:01

    $attachment =  array(
    'access_token' => $token,
    'message' => $msg,
    'name' => $title,
    'link' => $uri,
    'description' => $desc,
    'picture'=>$pic,
    'actions' => json_encode(array('name' => $action_name,'link' => $action_link))
    );
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/fbnameorid/feed');
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  //to suppress the curl output 
    $result = curl_exec($ch);
    curl_close ($ch);
    

提交回复
热议问题