extended permission using php sdk

后端 未结 1 1121
情书的邮戳
情书的邮戳 2021-01-27 02:48

I am developing a facebook application using php-sdk. i want to take some extended permissions from user of my application. As this is application where user comes after login i

相关标签:
1条回答
  • 2021-01-27 03:09

    check this

    `<?php 
    $app_id = "YOUR_APP_ID";
    $app_sec = "APP_SEC";
    $canvas_page = "APP_CANVAS_PAGE_URL";
    $scope = "&scope=user_photos,email,publish_stream";   $auth_url"http://www.facebook.com/dialog/oauth?client_id=" . $app_id . "&redirect_uri=" .   urlencode($canvas_page).$scope; 
    $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(""); } 
     $access_token = $data["oauth_token"]; 
    $user_id = $data["user_id"]; 
    $user = json_decode(file_get_contents( "https://graph.facebook.com/me?access_token=" .         $access_token)); 
    function get_facebook_cookie($app_id, $application_secret) { 
    $args = array();
    parse_str(trim($COOKIE["fbs" . $app_id], "\""), $args); 
    ksort($args);
    $payload = ""; 
    foreach ($args as $key => $value) { 
    if ($key != "sig") { 
    $payload .= $key . "=" . $value; 
    } 
    } 
    if (md5($payload . $application_secret) != $args["sig"]) {
    return null; 
    } 
    return $args; 
    } 
    $cookie = get_facebook_cookie($app_id, $app_sec); 
    ?>
    
    0 讨论(0)
提交回复
热议问题