Domanda

Mi è stato dato un codice da un amico che ha visualizzato la data di nascita degli utenti dell'app sulla tela dell'app.

Ho provato a modificarlo per riecheggiare l'ID utenti. Funziona per me stesso (il creatore) e funziona anche per un amico che ho designato come sviluppatore. Ma per chiunque altro provoca questo errore:

Warning: file_get_contents(https://graph.facebook.com/me?
fields=id&access_token=228073413942115|460d2e1ffd0b4cc6b5cb480d53f60d6e)
[function.file-get-contents]: failed to open stream: HTTP request failed! 
HTTP/1.0 400 Bad Request in /home/robsdmr/public_html/fb/index.php on line 34

Il codice è il seguente.

<?php
require_once("src/facebook.php");

$app_id = "xxxxxxxxxx";
$app_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";
$canvas_page = "https://apps.facebook.com/roblewtest/" .$app_id;


$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true,
));

$access_token = $facebook->getAccessToken();


$auth_url = "https://www.facebook.com/dialog/oauth?scope=user_id&client_id="
. $app_id . "&redirect_uri=" . urlencode($canvas_page);

$signed_request = $_REQUEST["signed_request"];

list($encoded_sig, $payload) = explode('.', $signed_request, 2);

$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);

if (empty($data["user_id"])) {
echo("<script> top.location.href='" . $auth_url . "'</script>");
} else {

}

$graph_url = "https://graph.facebook.com/me?fields=id&access_token=" . $access_token;
$result = json_decode(file_get_contents($graph_url));

echo "{$result->id}"

?>

Sono abbastanza nuovo per questo, quindi i suggerimenti sarebbero fantastici

Ho la sensazione che siano gli ambiti con cui non ho abbastanza prese, ma ho davvero bisogno di questo funzionamento.

Grazie mille ragazzi e gals.

R.

Nessuna soluzione corretta

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top