Agar foydalanuvchi o'z oauth_token-ga ega bo'lsa, foydalanuvchi qanday qilib erkin foydalanish mumkin?

Foydalanuvchi mening kanvas appni ochganda, men Facebookdan user_id va oauth_token dan olingan signed_request kodini olaman. Keyin access_token kodini qanday qilib olaman va foydalanuvchi ruxsatini va boshqa ma'lumotlarni tekshirib olamanmi?

4

3 javoblar

Siz aytayotgan oauth_token ham foydalanuvchilarning access_token, ular bir xil bo'lishi kerak.

Foydalanuvchilarning ruxsatlarini tekshirish uchun/me/ruxsatlarga GET chaqiruvini amalga oshirishingiz mumkin, bu quyida shunga o'xshash ma'lumotlar majmuasini qaytarishi kerak

{
  "data": [
    {
      "installed": 1, 
      "read_stream": 1, 
      "manage_notifications": 1, 
      "manage_pages": 1, 
      "user_likes": 1, 
      "user_activities": 1, 
      "user_interests": 1, 
      "user_photos": 1, 
      "user_about_me": 1, 
      "type": "permissions"
    }
  ]
}

Depending on what the other data you wish to access you will need to ask for more permissions and then call the appropriate API end points. For example to get the users basic information make a call to /me or to get a list of their friends /me/friends

You can find all the permissions you can ask for at https://developers.facebook.com/docs/reference/api/permissions/

And all the information about where to call in the API for retrieving the different bits of data you require here https://developers.facebook.com/docs/reference/api/

5
qo'shib qo'ydi

Sizning "oauth token" so'zlarini aytganda - kirish belgisi emasligiga aminmisiz? Ushbu kod bilan /me/permissions uchun API chaqiruvini amalga oshirishga harakat qilyapsizmi? U foydalanuvchining sizning ilovangizga bergan ruxsatnomalar ro'yxatini qaytarishi kerak (bu token orqali ishlatilishi mumkin)

1
qo'shib qo'ydi
    <?php
include '../../src/config.php';
// Get User ID
$user = $facebook->getUser();

// We may or may not have this data based on whether the user is logged in.
//
// If we have a $user id here, it means we know the user is logged into
// Facebook, but we don't know if the access token is valid. An access
// token is invalid if the user logged out of Facebook.

if ($user) {
  try {
   //Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}

// Login or logout url will be needed depending on current user state.
if ($user) {
  $logoutUrl = $facebook->getLogoutUrl();
  $access_token = $facebook->getAccessToken();
$user_xml = "<?xml version=\"1.0\"?>\n"; 
$user_xml .= "\n";
$user_xml .= "\n";
$user_xml .= "" . $access_token . "\n"; 
$user_xml .= "\n";
$user_xml .= "\n";
echo $user_xml; 



} else {
  $loginUrl = $facebook->getLoginUrl();
}




?>
1
qo'shib qo'ydi