我正在使用以下代码从Facebook获取信息,但不知道如何获取图片链接(iknow $ name = $ test [0];以及$ 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];
}
这是facebook的iframe
<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>
答案 0 :(得分:1)