如何使用twython获取带坐标的推文

时间:2015-02-26 20:10:46

标签: python twitter twython

我试图在这里得到推文是地理代码

    twitter = Twython(app_key, app_secret, oauth_token, oauth_token_secret)

searches = twitter.search_geo(q=keywords, lat = '25.032341', long = '55.385557', count=1, rad = '100mi')
print (searches)

得到的结果没有得到推文

{'query': {'type': 'search', 'url': 'https://api.twitter.com/1.1/geo/search.json?lat=25.032341&long=55.385557&rad=100mi&q=++-RT&count=1', 'params': {'coordinates': {'type': 'Point', 'coordinates': [55.385557, 25.032341]}, 'trim_place': False, 'query': '', 'autocomplete': False, 'granularity': 'neighborhood', 'accuracy': 0.0}}, 'result': {'places': [{'name': 'Dubai', 'contained_within': [{'name': 'United Arab Emirates', 'place_type': 'country', 'bounding_box': {'type': 'Polygon', 'coordinates': [[[51.2938738, 22.6261387], [51.2938738, 26.2823697], [56.3816989, 26.2823697], [56.3816989, 22.6261387], [51.2938738, 22.6261387]]]}, 'full_name': 'United Arab Emirates', 'centroid': [55.147370403855, 24.3556033], 'country': 'United Arab Emirates', 'country_code': 'AE', 'attributes': {}, 'url': 'https://api.twitter.com/1.1/geo/id/3f63906fc8aa5a7d.json', 'id': '3f63906fc8aa5a7d'}], 'place_type': 'admin', 'bounding_box': {'type': 'Polygon', 'coordinates': [[[54.8939725, 24.6182526], [54.8939725, 25.3686719], [56.2083722, 25.3686719], [56.2083722, 2

任何人都可以帮助我如何分离推文

1 个答案:

答案 0 :(得分:0)

Twython中,方法<?php // put this file in a folder, let's say /raw/something.php // load MODX without running request handler define('MODX_API_MODE', true); include 'path/to/modx/index.php'; $resource = $modx->newObject('modResource'); $resource->set('pagetitle', $pagetitle); $resource->set('alias', $alias); $resource->set('content', $content); $resource->set('template', $template); // IMPORTANT! it's where TVs are attached // and other $resource->set('fieldname', $variable); if ($resource->save()) { $resource->setTVValue('tvName_1', $value_1); $resource->setTVValue('tvName_2', $value_2); $resource->setTVValue('tvName_3', $value_3); $resource->setTVValue('tvName_4', $value_4); $resource->setTVValue('tvName_5', $value_5); } 用于查找提供的地理位置半径范围内的“地点”search_geo。您需要使用place_id方法,如下所示:

search