facebook php post photo
PHP script for posting to Facebook image/photo to page with Graph API. URL link with (PNG, JPG) file from your or other web-site.Type page Album ID if you want post image to page Album only. If you type Page ID, photo/image will be posted to Facebook page feed.
You will see post id and image id with successful request.
$access_token = "*******"; // token
$page_id = "******"; // page id, or user id, type Album ID if you want post image to Album only
$url = "https://graph.facebook.com/$page_id/photos";
$data = array(
'access_token' => $access_token,
'caption' => "test photo",
'url' => "http://lh5.googleusercontent.com/-QfoXx7AsqCU/AAAAAAAAAAI/AAAAAAAAANg/dvsM-z4RF-g/s512-c/photo.jpg",
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
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, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //to suppress the curl output
$result = curl_exec($ch);
curl_close ($ch);
print_r ($result);
Photo was saved in album.
https://www.facebook.com/chakabiz
https://www.youtube.com/channel/UCYuMRNb_SRZ4FMsZjnHRZUA
No comments:
Post a Comment