Question

i'm using the code below to fetch information from facebook but don't know how to get the image link (iknow $name = $test[0]; and $email = $test[4];)

define('FACEBOOK_APP_ID', '331805196916042');
define('FACEBOOK_SECRET', '9fc1c6714fb4b4dfba5acb780714ea60');

function parse_signed_request($signed_request, $secret) {
list($encoded_sig, $payload) = explode('.', $signed_request, 2); 

// decode the data
$sig = base64_url_decode($encoded_sig);
$data = json_decode(base64_url_decode($payload), true);

if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
error_log('Unknown algorithm. Expected HMAC-SHA256');
return null;
}

// check sig
$expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
if ($sig !== $expected_sig) {
error_log('Bad Signed JSON signature!');
return null;
}

return $data;
}

function base64_url_decode($input) {
return base64_decode(strtr($input, '-_', '+/'));
}

if ($_REQUEST) {
$response = parse_signed_request($_REQUEST['signed_request'], 
                               FACEBOOK_SECRET);
} else {
echo '$_REQUEST is empty';
}

foreach($response as $res){
foreach($res as $val){
    $test[] = $val; 
}
}



foreach($test[3] as $address){
$address1[] = $address; 
 }


if(strstr($address1[0],",")){
    $country = end(explode(",",$address1[0]));
    $add = explode(",",$address1[0]);
//echo $add[0]." ".$add[1]." ".$add[2];
}

and here's the iframe of facebook

<iframe src="https://www.facebook.com/plugins/registration?client_id=331805196916042&redirect_uri=http://www.mawk3y.net/news2/data.php&source=fb&fields=name,birthday,gender,location,email,first_name,last_name"
    scrolling="auto"
    frameborder="no"
    style="border:none"
    allowTransparency="true"
    width="100%"
    height="530">
</iframe>
Was it helpful?

Solution

The picture is accessible by the following url:

http://graph.facebook.com/[user-login]/picture

For instance for Mark Zuckerberg it will be:

http://graph.facebook.com/zuck/picture

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top