Friday, February 18, 2011

Facebook app request

how to get facebook apprequest receiver user id

<a onclick="facebook_invitess_users(); return false;" href="#" class="link2">click here</a>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({appId: 'your_appid', status: true, cookie: true, xfbml: true});
};

FB.init({appId: 'your_appid', status: true, cookie: true, xfbml: true});

var facebook_invitess_users = function() {

FB.ui(
{
method: 'apprequests',
message: rebuild,
data: 'tracking information for the user',
title: 'Choose the friends you would like to invite',

},
function(response) {
jQuery.post(
"submit_url",
{request_ids: response.request_ids},
function(data) { alert(data); },
"html"
);
}
);


}

</script>

submit url php file code

<?php
if(isset($_REQUEST['request_ids'])) {
$sent = $_REQUEST['request_ids']; //Convert csv to array
$count = count($sent); //count how many objects in array

$appid = 'facebook_app_id';
$secret = 'facebook_app_secrct';
$app_token = file_get_contents('https://graph.facebook.com/oauth/access_token?client_id='.$appid.'&client_secret='.$secret.'&grant_type=client_credentials');

//Get application token
for ($a = 0; $a < $count; $a++) {

$request = file_get_contents('https://graph.facebook.com/'.$sent[$a].'?'.$app_token);

print_r($request); // This will output like below

$arr = json_decode($request);
var_dump($arr);
print_r($arr->to->name);
print_r($arr->to->id);

}

}
?>

how to see xml preview in browser php

xml preview view in browser $xml = new DOMDocument('1.0', 'UTF-8');                 $xml->preserveWhiteSpace = false; ...