Saturday, January 8, 2011

Post on facebook wall from my website

Here is the php-curl script where you can post on facebook wall through your web site.

require_once 'facebook/facebook.php';
$aplication_id='YOUR_APPLICATION_KEY';
$facebook_api_key='YOUR_API_KEY';
$facebook_api_secret='YOUR_SECRET_KEY';

$facebook = new Facebook(array(
'appId' => $facebook_api_key,
'secret' => $facebook_api_secret,
'cookie' => true
));

//------------------Access Token---------------------------------------

$param='fbs_'.$aplication_id;
$string=substr($_COOKIE[$param], 15, strlen($_COOKIE[$param])-15); // we got the access token
$arr=explode("&",$string);
$token=$arr[0];

$_curl = curl_init();
curl_setopt($_curl, CURLOPT_URL, "https://graph.facebook.com/me/feed?access_token=".$token);
curl_setopt($_curl, CURLOPT_HEADER, false);
curl_setopt($_curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($_curl, CURLOPT_POST, true);
curl_setopt($_curl, CURLOPT_POSTFIELDS, $arr_attachment);
curl_setopt($_curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($_curl, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec ($_curl);
curl_close($_curl);

?>













Wall Post

Enter Message:
Enter Link:
Enter Title:
Enter Caption:
Enter Description:


FaceBook Graph API

At Facebook's core is the social graph; people and the connections they have to everything they care about. The Graph API presents a simple, consistent view of the Facebook social graph, uniformly representing objects in the graph (e.g., people, photos, events, and pages) and the connections between them (e.g., friend relationships, shared content, and photo tags).

Every object in the social graph has a unique ID. You can access the properties of an object by requesting https://graph.facebook.com/ID. For example, the official page for the Facebook Platform has id 19292868552, so you can fetch the object at https://graph.facebook.com/19292868552:

Alternatively, people and pages with usernames can be accessed using their username as an ID. Since "platform" is the username for the page above, https://graph.facebook.com/platform will return what you expect. All responses are JSON objects.

All objects in Facebook can be accessed in the same way:

All of the objects in the Facebook social graph are connected to each other via relationships. Bret Taylor is a fan of the Coca-Cola page, and Bret Taylor and Arjun Banker are friends. We call those relationships connections in our API. You can examine the connections between objects using the URL structure https://graph.facebook.com/ID/CONNECTION_TYPE. The connections supported for people and pages include:

We support different connection types for different objects. For example, you can get the list of all the people attending the Facebook Developer Garage at SXSW (ID #331218348435) by fetching https://graph.facebook.com/331218348435/attending?access_token=....