How get facebook user ID from my application?

后端 未结 4 1514
傲寒
傲寒 2020-12-21 18:20

I created a facebook application and send request to a user through below code.Now when a user allow my application then i need his id and email address into my canvas url.B

4条回答
  •  佛祖请我去吃肉
    2020-12-21 18:47

    At last i solve my problem and now i can easily get the facebook user id and email address and other related information.Using this code i can hit to facebook for particular user's authentication and when user accept my application then i can get his/her facebook user id, email and other information into $user_info array.Hope it will help you.

    Just see my code below:

     '########',
      'secret' => '##########################',
      'cookie' => true,
    ));
    
    $req_perms = "publish_stream,offline_access,user_status,email,read_stream"; 
    $session = $facebook->getSession();
    $loginUrl = $facebook->getLoginUrl(array('canvas'=> 1,'fbconnect' => 0,'req_perms' => $req_perms));
    $user_info = null;
    if (!$session) 
        { echo "";exit;}
    else{
         try {  $user_info = $facebook->api('/me');  } 
         catch (FacebookApiException $e) 
             { echo ""; exit;}
        }
    ?>
    
    
    
    
    
    "; 
    echo "Hi $user_name ! Your E-mail Address is: ".$user_info['email']."
    "; echo "Thanks for accepting our application."; //print_r($user_info); ?>

提交回复
热议问题