I'm trying to use this module to get a list of venues, given some coordinates.
My code is:

  $fsObj = foursquare_get_object();
  $fsObj->useSSL(true);
  $fsObj->useApiVersion('v2');
  $fs_venues = $fsObj->get('/venues/search', array('ll' => $latitude . "," . $longitude, 'intent' => 'checkin', 'radius' => 1000));

When run, I get an error: "OAuth token invalid or revoked"
I know I didn't call foursquare_get_object() with the uid of the user, but in the documentation at https://developer.foursquare.com/docs/venues/search they say: " If authenticated, the method will return venue metadata related to you and your friends. If you do not authenticate, you will not get this data."
What am I doing wrong?

Comments

mottolini’s picture

Status: Active » Closed (fixed)

I made it works, but I had to hack the EpiFoursquare.php file.
The code has to be:

  $consumer_key = variable_get('foursquare_consumer_key', ''); 
  $consumer_secret = variable_get('foursquare_consumer_secret', '');
  $fsObj = foursquare_get_object();
  $fsObj->useSSL(true);
  $fsObj->useApiVersion('v2');
  $fs_venues = $fsObj->get_basic('/venues/search', array('ll' => $latitude . "," . $longitude, 'intent' => 'checkin', 'radius' => 1000, 'v' => '20120404', 'client_id' => $consumer_key, 'client_secret' => $consumer_secret));

I had to add client_id and client_secret parameters beacuse these are required when you don't make an oauth call on behalf of a real Foursquare user. Also I had to use get_basic function instead of get. The problem is that get_basic completely ignores settings made with useSSL and useApiVersion, making in fact only v1 calls without ssl. To make it works, you have to change line 119 of EpiFoursquare.php into:

    $url = $this->getUrl($this->getApiUrl($endpoint));
mottolini’s picture

And here is the patch, which solves the issue #927850 as well.

mottolini’s picture

Status: Closed (fixed) » Patch (to be ported)