jublo / codebird-php

Easy access to the Twitter REST API, Direct Messages API, Account Activity API, TON (Object Nest) API and Twitter Ads API — all from one PHP library.
https://www.jublo.net/projects/codebird/php
GNU General Public License v3.0
775 stars 237 forks source link

I cannot send a geolocation search. #233

Closed okrauth closed 5 years ago

okrauth commented 6 years ago

I am testing the library. Is there a way to send a geo location search request using only the Application-only auth? How do I submit the lat lon param?

thanks!

mynetx commented 5 years ago

Hi @okrauth,

As outlined in Twitter’s Standard search API docs, you may send your desired latitude and longitude coordinates as a comma-separated value in the geocode parameter.

Take a look at this sample code:

require_once 'src/codebird.php';

\Codebird\Codebird::setConsumerKey('Your-consumer-key', 'Your-consumer-secret');
$cb = \Codebird\Codebird::getInstance();
$cb->setToken("Your-token", "Your-secret");

$reply = $cb->search_tweets([
    'geocode' => '53.8251523,-1.6265369,3mi'
]);

var_dump($reply);

The 53.82... value is the latitude, -1.62... stands for the longitude, and the third parameter contains the radius from this point (in either km or mi).

Hope this helps?

mynetx commented 5 years ago

@okrauth Did you have time to try the code above?

mynetx commented 5 years ago

Closing since there were no further replies.