Showing posts with label Facebook autopost. Show all posts
Showing posts with label Facebook autopost. Show all posts

Monday 7 April 2014

Facebook Auto Post functionality


<?php
$url="http://google.com";
$title="Test Content";
$message = "$title $url";
$fb_access_token = "----";  // FB access token
$fb_user_id ="---";   //Facebook user id
$post_arg = array("access_token" => $fb_access_token, "message" => $message, "id" => $fb_user_id, "method" => "post");
fb_curl_function("https://graph.facebook.com/feed", "POST", $post_arg);

function fb_curl_function($req_url = "", $type = "", $arguments =  array()){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $req_url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
if($type == "POST"){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $arguments);
}
$result = curl_exec($ch);
curl_close ($ch);
return $result;
}

?>