Hi! I have been trying to post on my own wall page but nothing happens till now. I have an app and everytime i was submitted/ everytime a user visits it, i want it to post a link on my own page as page not user. i have this code. but still doesnt work. hope i can find help here. i've been to many forums but no help still. thanks alot in advance!
heres's my code:
$fb_user_id = $facebook->getUser();
$location = "". $facebook->getLoginUrl(array('scope' => 'publish_stream'));
if ($fb_user_id) {
try {
$page_access_token = "appid|appsecret";
$result = $facebook->api("/me/accounts");
foreach($result["data"] as $page) {
if($page["id"] == $page_id) {
//$page_access_token = $page["access_token"];
$page_access_token = $facebook->api("/".FB_PAGE_ID."?fields=access_token");
break;
}
}
$attachment = array(
'message' => $post_msg,
'link' => $post_link,
'access_token' => $page_access_token,
);
$facebook->api("/".FB_PAGE_ID.'/feed', 'POST', $attachment);
} catch (FacebookApiException $e) {
$fb_user_id = NULL;
// seems we don't have enough permissions
// we use javascript to redirect user instead of header() due to Facebook bug
print '<script language="javascript" type="text/javascript"> top.location.href="'. $location .'"; </script>';
// kill the code so nothing else will happen before user gives us permissions
die();
}
} else {
// seems our user hasn't logged in, redirect him to a FB login page
print '<script language="javascript" type="text/javascript"> top.location.href="'. $location .'"; </script>';
// kill the code so nothing else will happen before user gives us permissions
die();
}