Hai,
How can i post my date to facebook post from php form/page (Title,Description,image)
any suggestion please,
Hai,
How can i post my date to facebook post from php form/page (Title,Description,image)
any suggestion please,
thanks for your input…,
this is what i am trying to do
function doWallPost($postName = ‘’, $postMessage = ‘’, $postLink = ‘’, $postCaption = ‘’, $postDescription = ‘’) {
$FB_APP_ID = ‘’;
$FB_APP_SECRET = '****’;
$APP_RETURN_URL = ((substr($_SERVER[‘SERVER_PROTOCOL’], 0, 4) == “HTTP”) ? “http://” : “https://”) . $_SERVER[‘HTTP_HOST’] .
$_SERVER[‘SCRIPT_NAME’];
$code = $_REQUEST[“code”];
if (empty($code)) {
$dialog_url = “http://www.facebook.com/dialog/oauth?client_id=” . $FB_APP_ID . “&redirect_uri=” . $APP_RETURN_URL . “&scope=publish_stream”;
header(“Location:$dialog_url”);
}
$token_url = “https://graph.facebook.com/oauth/access_token?client_id=” . $FB_APP_ID . “&redirect_uri=” . urlencode($APP_RETURN_URL) . “&client_secret=” . $FB_APP_SECRET . “&code=” . $code;
$access_token = file_get_contents($token_url);
$param1 = explode("&", $access_token);
$param2 = explode("=", $param1[0]);
$FB_ACCESS_TOKEN = $param2[1];
$url = “https://graph.facebook.com/me/feed”;
$attachment = array(
‘access_token’ => $FB_ACCESS_TOKEN,
‘name’ => $postName,
‘link’ => $postLink,
‘description’ => $postDescription,
‘message’ => $postMessage,
‘caption’ => $postCaption
);
$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_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
$result = curl_exec($ch);
header(‘Content-type:text/html’);
curl_close($ch);
return $result;
}
thanks,
So what now? CURL returns a result. And without the secret nobody can test that.
@chorn this is my new code
$page_access_token = '*****';
$page_id = '*****';
$data['picture'] = "http://www.example.com/image.jpg";
$data['link'] = "http://www.example.com/";
$data['message'] = "Your message";
$data['caption'] = "Caption";
$data['description'] = "Description";
$data['access_token'] = $page_access_token;
$post_url = 'https://graph.facebook.com/'.$page_id.'/feed';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$return = curl_exec($ch);
curl_close($ch);
is there any mistake…?
thanks,
Darshan
Still CURL returns a result, look at that.
Graph returned an error: (#200) If posting to a group, requires app being installed in the group, and \ either publish_to_groups permission with user token, or both manage_pages \ and publish_pages permission with page token; If posting to a page, \ requires both manage_pages and publish_pages as an admin with \ sufficient administrative permission
This error is showing …