Below is the core code using the facebook graph API in PHP, cURL is required:
It is assumed the PHP variables containing proper data.the $attachment array keys can be added or removed necessarily.
It is assumed the PHP variables containing proper data.the $attachment array keys can be added or removed necessarily.
<?php
$ch = curl_init();
$url="https://graph.facebook.com/<PAGE ID>/feed?access_token=<APP API KEY>|<APP Secret>";
$attachment = array(
'access_token' => "$access_token",
'message' =>"$message",
'name' => "New Session!",
'link' => "$purl",
'description' => ' ',
'picture'=>"<PICTURE URL>",
);
'access_token' => "$access_token",
'message' =>"$message",
'name' => "New Session!",
'link' => "$purl",
'description' => ' ',
'picture'=>"<PICTURE URL>",
);
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, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_exec($ch);
curl_close ($ch);
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, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_exec($ch);
curl_close ($ch);
?>
No comments :
Post a Comment