无法从 ZF2 Twitter 用户搜索中获取 属性
Cannot get derived property from ZF2 Twitter user search
我正在使用 ZF2 Twitter 包通过用户名获取用户信息并检索它的位置,但是 returned 对象没有给我 "derived" 属性,那个应该有关于我想使用的位置的详细数据。
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 作为参考
这是我 return 用户
得到的回复
{
'placename: ': '-',
'link: ': 'http://www.google.com/maps/place/,',
}
如何检索这些数据?
来自该页面:
Profile Geo data will be included in Twitter's PowerTrack, Replay, Volume Stream, Search, and Historical PowerTrack APIs.
我认为 这意味着地理数据仅适用于 paying customers of PowerTrack。如果你只是一个普通的开发者,是无法获取的。
我正在使用 ZF2 Twitter 包通过用户名获取用户信息并检索它的位置,但是 returned 对象没有给我 "derived" 属性,那个应该有关于我想使用的位置的详细数据。
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 作为参考
这是我 return 用户
得到的回复{
'placename: ': '-',
'link: ': 'http://www.google.com/maps/place/,',
}
如何检索这些数据?
来自该页面:
Profile Geo data will be included in Twitter's PowerTrack, Replay, Volume Stream, Search, and Historical PowerTrack APIs.
我认为 这意味着地理数据仅适用于 paying customers of PowerTrack。如果你只是一个普通的开发者,是无法获取的。