代码之家  ›  专栏  ›  技术社区  ›  Salustiano Muniz

无法从ZF2 Twitter用户搜索中获取派生属性

  •  0
  • Salustiano Muniz  · 技术社区  · 6 年前

    我使用zf2twitter包通过用户名获取用户信息并检索其位置,但是返回的对象没有给我“派生”属性,该属性应该包含有关我要使用的位置的详细数据。

    public function twitterAction()
    {
        $config = array(
            'access_token' => array(
                'token' => 'MY TOKEN',
                'secret' => 'MY SECRET',
            ),
            'oauth_options' => array(
                'consumerKey' => 'MY CONSUMER KEY',
                'consumerSecret' => 'MY COMSUMER SECRET',
            ),
            'http_client_options' => array(
                'adapter' => 'Zend\Http\Client\Adapter\Curl',
                'curloptions' => array(
                    CURLOPT_SSL_VERIFYHOST => false,
                    CURLOPT_SSL_VERIFYPEER => false,
                ),
            ),
        );
        $twitter = new Twitter($config);
        $response = $twitter->account->accountVerifyCredentials();
        if (!$response->isSuccess()) {
            die(var_dump($response->getErrors()));
        }
        $params = $this->params()->fromRoute();
        $profile = $params['profile'];
        $user = $twitter->users->show($profile);
        $coordinates = $user->derived->geo->coordinates;
    
        return new JsonModel(
         [
             'placeName' => $user->derived->locality . ' - ' $user->derived->region,
             'link' => 'http://www.google.com/maps/place/'.$coordinates[0].','.$coordinates[1]
         ]
     );
    }
    

    the twitter api page 作为参考

    这是返回用户时得到的响应

    {
        'placename: ': '-',
        'link: ': 'http://www.google.com/maps/place/,',
    }
    

    如何检索这些数据?

    1 回复  |  直到 6 年前
        1
  •  0
  •   Terence Eden    6 年前

    从那一页:

    个人资料地理数据将包含在Twitter的PowerTrack、Replay、Volume Stream、Search和历史PowerTrack API中。

    这意味着地理数据只能用于 paying customers of PowerTrack . 如果你只是一个普通的开发人员,你不可能得到它。