We can create an Facebook APP id and its secret code. Now You can use this below code for post the dynamic products to Facebook Wall post..
/*************** Facebook wall post ***************/
require "facebook/src/facebook.php";
$app_id = "00000000000000000";
$app_secret = "000000000000000000000000000000000";
// Init facebook api.
$facebook1 = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$user = $facebook1->getUser();
if ($user)
{
try
{
$user_profile = $facebook1->api('/me?fields=id,email');
$email=$user_profile['email'];
$id=$user_profile['id'];
$post_url = '/me/feed';
$msg_body = array(
'message' => $product_type.": ".$_SESSION['list_product_title1'],
'link' => $SITE_URL."post_list.php?uid=".$tmpid_list."&post=".md5($tmpid_list),
'name' => $_SESSION['list_product_title1'],
'caption' => $_SESSION['list_product_title1']
);
if ($user) {
try {
$postResult = $facebook1->api($post_url, 'post', $msg_body );
}
catch (FacebookApiException $e) {
echo $e->getMessage();
}
}
}
catch(FacebookApiException $e){
$facebook1->destroySession();
}
}
/*************** Facebook wall post ***************/
/*************** Facebook wall post ***************/
require "facebook/src/facebook.php";
$app_id = "00000000000000000";
$app_secret = "000000000000000000000000000000000";
// Init facebook api.
$facebook1 = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$user = $facebook1->getUser();
if ($user)
{
try
{
$user_profile = $facebook1->api('/me?fields=id,email');
$email=$user_profile['email'];
$id=$user_profile['id'];
$post_url = '/me/feed';
$msg_body = array(
'message' => $product_type.": ".$_SESSION['list_product_title1'],
'link' => $SITE_URL."post_list.php?uid=".$tmpid_list."&post=".md5($tmpid_list),
'name' => $_SESSION['list_product_title1'],
'caption' => $_SESSION['list_product_title1']
);
if ($user) {
try {
$postResult = $facebook1->api($post_url, 'post', $msg_body );
}
catch (FacebookApiException $e) {
echo $e->getMessage();
}
}
}
catch(FacebookApiException $e){
$facebook1->destroySession();
}
}
/*************** Facebook wall post ***************/
No comments:
Post a Comment