0

I'm trying to get geolocation from tweets. For my tests, I posted new tweets geo-referenced but when I got the json of them, the element 'geo' is null. Why? What's wrong with them?

I don't want to search by range and geolocation: I want to search some tweets indexed by a particular hashtag and then retrieve 'geo' json element. I tried to search other tweets (not mine) and sometimes I got 'geo' element as a full object, with coordinates array.

So, what can I do to have 'geo' element not null?

I did 4 posts geo-referenced: my tweets

The location is: 44.694704,10.528611

Edit: Added geocode param

This is what I've done server-side (pure php):

$conn = new OAuth (CONSUMER_KEY, CONSUMER_SECRET);
$conn->setToken (ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$conn->fetch (API_URL, array ('q' => '#testhashtagandgeo', 'geocode' => '44.694704,10.528611,4km'));
echo $conn->getLastResponse ();

I used PHP OAuth base and each constant is defined correctly, so it works good.

Client-side (ExtJS):

Ext.onReady (function () {
    Ext.Ajax.request ({
        url: 'proxy.php' ,
        disableCaching: false ,
        success: function (xhr) {
            var js = Ext.JSON.decode (xhr.responseText);
            Ext.each (js.results, function (tweet) {
                if (tweet.geo !== null) {
                    console.log ('lat = ' + tweet.geo.coordinates[0] + ' - lng = ' + tweet.geo.coordinates[1]);
                }
            });
            console.log (js);
        } ,
        failure: function (xhr) {
            console.log ('something\'s wrong!');
        }
    });
});

Thanks in advance.

Wilk

4

1 に答える 1

0

ドキュメントを読む必要があります

位置データは、クエリに地理コードパラメータが含まれ、ユーザーが地理情報をツイートした場合にのみ含まれます。

したがって、このようなものをクエリに追加する必要があります

&geocode=37.781157,-122.398720,25mi

または、任意の場所。

于 2012-05-22T15:37:17.420 に答える