Tuesday, May 8, 2012

facebook request reading and user_id geting issue

Hi im sending my request like this



 <?php 
$app_id = "127736900693315";

$canvas_page = "http://apps.facebook.com/greetingz";

$message = "Dynamic_msg";
$data_s="Dynamic_data";


$requests_url = "https://www.facebook.com/dialog/apprequests?app_id="
. $app_id . "&redirect_uri=" . urlencode($canvas_page)
. "&message=" . $message."&data=".$data_s;

if (empty($_REQUEST["request_ids"])) {
echo("<script> top.location.href='" . $requests_url . "'</script>");


} else {

}
?>


this request is going ok but when receiver click on notification im fetching through request_ids code is below



    if(!empty($_REQUEST['request_ids'])) {

$config = array(
'appId' => '343704039016593',
'secret' => '56e711bf93d4e46426aa662c8be8d5ef',
'cookie' => true,

);
$facebook = new Facebook($config);
echo $user_id= $facebook->getUser(); //** 0 printing**
$app_token = $facebook->getAccessToken();

$requests = explode(',',$_REQUEST['request_ids']);
foreach($requests as $request_id) {

$request_content = json_decode(file_get_contents("https://graph.facebook.com/'".$request_id."_".$user_id."'?access_token=$app_token"), TRUE);
print_r($request_content); //**nothing is printing**


$deleted = file_get_contents("https://graph.facebook.com/$request_id?access_token=$app_token&method=delete");





}


I dono whats wrong on my coding im trying almost 7 days and I checked tutorial online most of those are old now the API have updated. I cant get the user_id even ... do I need to send my request OAuth Dialog??
}





No comments:

Post a Comment