-2

首先对这个愚蠢的问题感到抱歉,我正在尝试从 facebook 获取数据。我已经为我的网站设置了 facebook 应用程序,正在获取数据,但是当我将位置(Facebook 信息)设置为私有时,返回的数据不包含位置数据。

这是模型

class Facebook_model extends CI_Model {

public function __construct()
{
    parent::__construct();

    $config = array(
                    'appId'  => 'APP_ID',
                    'secret' => 'SECRET',
                    'fileUpload' => true, 
                    );

    $this->load->library('Facebook', $config);

    $user = $this->facebook->getUser();
    $profile = null;
    if($user)
    {
        try
        {
            $profile = $this->facebook->api("/me", 'get');
        }catch(FacebookApiException $e)
        {
            error_log($e);
            $user = null;
        }
    }

    $fb_data = array(
        'me' => $profile,
        'uid' => $user,
        'loginUrl' => $this->facebook->getLoginUrl(
            array(
                    'scope' => 'email,publish_stream,user_about_me,user_checkins,publish_stream,friends_about_me',
                    'redirect_uri' => base_url() . 'index.php/welcome/topsecret/'
                )
            ), 
        'logoutUrl' => $this->facebook->getLogoutUrl()  
    );

    $this->session->set_userdata('fb_data', $fb_data);

      }

这是我的虚拟帐户的输出,即隐私设置为公开

 Array
(
   [me] => Array
     (
        [id] => 100004160084328
        [name] => Dave Batista
        [first_name] => Dave
        [last_name] => Batista
        [link] => http://www.facebook.com/dave.batista.355
        [username] => dave.batista.355
        [birthday] => 08/03/1991
        [hometown] => Array
            (
                [id] => 106050279435951
                [name] => Quezon City, Philippines
            )

        [location] => Array
            (
                [id] => 106050279435951
                [name] => Quezon City, Philippines
            )

        [gender] => male
        [email] => davebatista@gmail.com
        [timezone] => 8
        [locale] => en_GB
        [updated_time] => 2012-08-12T23:38:18+0000
    )

[uid] => 100004160084328
[loginUrl] => https://www.facebook.com/dialog/oauth?       client_id=266349843476112&redirect_uri=http%3A%2F%2Fpractice.com%2Findex.php%2Fwelcome%2Ftopsecret%2F&state=5d41b131b2d1e631e721cd0f6a1056aa&scope=email%2Cpublish_stream%2Cuser_about_me%2Cuser_checkins%2Cpublish_stream%2Cfriends_about_me
[logoutUrl] => https://www.facebook.com/logout.php?next=http%3A%2F%2Fpractice.com%2Findex.php%2Fwelcome%2Ftopsecret%2F&access_token=AAADyPmfObpABABJKZCZBdAXy3iPJyu4qRFEAPI8XpWS94iFZAtvnnMDkzb8yBjgQQQ8oe2O38g9QzqN834jA9axvTT0RkulRBtNItTOIAZDZD
)
4

2 回答 2

0
  1. 在 facebook 应用程序中为 user_location 获取用户和朋友权限
  2. 利用

    $param = array('scope' =>'email,user_location,user_birthday,offline_access', 'redirect_uri' => base_url() ); 重定向($this->fb_connect->getLoginUrl($param));

于 2012-08-14T03:51:04.103 回答
0

尝试将“user_location”添加到您的 $fb_data['loginUrl']['scope']。以下是您可以在 FB API 中使用的所有权限的列表:https ://developers.facebook.com/docs/authentication/permissions/

于 2012-08-13T05:25:02.783 回答