<tfoot id='xslP0'></tfoot>
      <i id='xslP0'><tr id='xslP0'><dt id='xslP0'><q id='xslP0'><span id='xslP0'><b id='xslP0'><form id='xslP0'><ins id='xslP0'></ins><ul id='xslP0'></ul><sub id='xslP0'></sub></form><legend id='xslP0'></legend><bdo id='xslP0'><pre id='xslP0'><center id='xslP0'></center></pre></bdo></b><th id='xslP0'></th></span></q></dt></tr></i><div id='xslP0'><tfoot id='xslP0'></tfoot><dl id='xslP0'><fieldset id='xslP0'></fieldset></dl></div>
      • <bdo id='xslP0'></bdo><ul id='xslP0'></ul>

      <small id='xslP0'></small><noframes id='xslP0'>

      <legend id='xslP0'><style id='xslP0'><dir id='xslP0'><q id='xslP0'></q></dir></style></legend>
      1. FACEBOOK SDK v4 返回空白电子邮件地址

        时间:2023-10-30
        1. <legend id='N9RNg'><style id='N9RNg'><dir id='N9RNg'><q id='N9RNg'></q></dir></style></legend>

            <tfoot id='N9RNg'></tfoot>
              <tbody id='N9RNg'></tbody>

            <small id='N9RNg'></small><noframes id='N9RNg'>

              <i id='N9RNg'><tr id='N9RNg'><dt id='N9RNg'><q id='N9RNg'><span id='N9RNg'><b id='N9RNg'><form id='N9RNg'><ins id='N9RNg'></ins><ul id='N9RNg'></ul><sub id='N9RNg'></sub></form><legend id='N9RNg'></legend><bdo id='N9RNg'><pre id='N9RNg'><center id='N9RNg'></center></pre></bdo></b><th id='N9RNg'></th></span></q></dt></tr></i><div id='N9RNg'><tfoot id='N9RNg'></tfoot><dl id='N9RNg'><fieldset id='N9RNg'></fieldset></dl></div>

                  <bdo id='N9RNg'></bdo><ul id='N9RNg'></ul>
                • 本文介绍了FACEBOOK SDK v4 返回空白电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 facebook sdk v4,但我似乎无法获得电子邮件地址.这是我的代码.我已经搜索了互联网上的每一个链接并尝试了每一件事.还尝试了不同的脚本,但我仍然收到空电子邮件.这是我的代码.

                  I'm using facebook sdk v4 and i can't seem to get the EMAIL ADDRESS. Here is my code. I have searched each and every link on internet and tried every thing. Also tried different scripts but still i'm getting null email. Here is my code.

                  /* INCLUSION OF LIBRARY FILEs*/
                      require_once( 'lib/Facebook/FacebookSession.php');
                      require_once( 'lib/Facebook/FacebookRequest.php' );
                      require_once( 'lib/Facebook/FacebookResponse.php' );
                      require_once( 'lib/Facebook/FacebookSDKException.php' );
                      require_once( 'lib/Facebook/FacebookRequestException.php' );
                      require_once( 'lib/Facebook/FacebookRedirectLoginHelper.php');
                      require_once( 'lib/Facebook/FacebookAuthorizationException.php' );
                      require_once( 'lib/Facebook/GraphObject.php' );
                      require_once( 'lib/Facebook/GraphUser.php' );
                      require_once( 'lib/Facebook/GraphSessionInfo.php' );
                      require_once( 'lib/Facebook/Entities/AccessToken.php');
                      require_once( 'lib/Facebook/HttpClients/FacebookCurl.php' );
                      require_once( 'lib/Facebook/HttpClients/FacebookHttpable.php');
                      require_once( 'lib/Facebook/HttpClients/FacebookCurlHttpClient.php');
                  
                  /* USE NAMESPACES */
                  
                      use FacebookFacebookSession;
                      use FacebookFacebookRedirectLoginHelper;
                      use FacebookFacebookRequest;
                      use FacebookFacebookResponse;
                      use FacebookFacebookSDKException;
                      use FacebookFacebookRequestException;
                      use FacebookFacebookAuthorizationException;
                      use FacebookGraphObject;
                      use FacebookGraphUser;
                      use FacebookGraphSessionInfo;
                      use FacebookFacebookHttpable;
                      use FacebookFacebookCurlHttpClient;
                      use FacebookFacebookCurl;
                  
                  /*PROCESS*/
                  
                      //1.Stat Session
                       session_start();
                  
                      //check if users wants to logout
                       if($_REQUEST['logout']==1){
                          unset($_SESSION['fb_token']);
                       }
                  
                      //2.Use app id,secret and redirect url 
                      $app_id = 'xxxxxxxxxx';
                      $app_secret = 'xxxxxxxxxxxxxxx';
                      $redirect_url='http://someurl.com/';
                  
                      //3.Initialize application, create helper object and get fb sess
                       FacebookSession::setDefaultApplication($app_id,$app_secret);
                       $helper = new FacebookRedirectLoginHelper($redirect_url);
                       $sess = $helper->getSessionFromRedirect();
                  
                      //check if facebook session exists
                      if(isset($_SESSION['fb_token'])){
                          $sess = new FacebookSession($_SESSION['fb_token']);
                      }
                  
                      //logout
                      $logout = 'http://dryvr.co/fb/?logout=1';
                  
                      //4. if fb sess exists echo name 
                          if(isset($sess)){
                              //store the token in the php session
                              $_SESSION['fb_token']=$sess->getToken();
                              //create request object,execute and capture response
                              $request = new FacebookRequest($sess,'GET','/me');
                              // from response get graph object
                              $response = $request->execute();
                              $graph = $response->getGraphObject(GraphUser::classname());
                              // use graph object methods to get user details
                              $name = $graph->getName();
                              $id = $graph->getId();
                              $image = 'https://graph.facebook.com/'.$id.'/picture?width=300';
                              $email = $graph->getProperty('email');
                              echo "hi $name <br>";
                              echo "your email is $email <br><Br>";
                              echo "<img src='$image' /><br><br>";
                              echo "<a href='".$logout."'><button>Logout</button></a>";
                          }else{
                              //else echo login
                              echo '<a href="'.$helper->getLoginUrl(array('email')).'" >Login with facebook</a>';
                          }
                  

                  我使用了 $email = $graph->getProperty('email'); 但我仍然无法访问电子邮件地址并且它返回空白电子邮件.我该怎么办?想法?

                  I have used $email = $graph->getProperty('email'); but still I can not access the email address and it is returning blank email. What should I do? Thoughts?

                  推荐答案

                  在这里看看我的回答:

                  • 如何从 Facebook API 版本 v2.4 获取用户电子邮件和生日

                  您需要指定要从 v2.4 开始的 Graph API 返回的每个字段,例如

                  You need to specify each field you want returned from the Graph API starting with v2.4, e.g.

                  $request = new FacebookRequest($sess,'GET','/me?fields=id,name,email');
                  

                  这一切都在 Facebook 文档中.

                  It's all in the Facebook docs.

                  这篇关于FACEBOOK SDK v4 返回空白电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:列出 Amazon S3 上特定文件夹中的对象 下一篇:嘿,如何从 laravel 中的 klaviyo php-sdk 在 laravel 中收集短信同意

                  相关文章

                    <bdo id='63m4U'></bdo><ul id='63m4U'></ul>

                    1. <i id='63m4U'><tr id='63m4U'><dt id='63m4U'><q id='63m4U'><span id='63m4U'><b id='63m4U'><form id='63m4U'><ins id='63m4U'></ins><ul id='63m4U'></ul><sub id='63m4U'></sub></form><legend id='63m4U'></legend><bdo id='63m4U'><pre id='63m4U'><center id='63m4U'></center></pre></bdo></b><th id='63m4U'></th></span></q></dt></tr></i><div id='63m4U'><tfoot id='63m4U'></tfoot><dl id='63m4U'><fieldset id='63m4U'></fieldset></dl></div>
                      <legend id='63m4U'><style id='63m4U'><dir id='63m4U'><q id='63m4U'></q></dir></style></legend>

                      <small id='63m4U'></small><noframes id='63m4U'>

                      <tfoot id='63m4U'></tfoot>