Gowalla API Class (php)

// april 14th, 2010 // api, Cuvedev, Development, gowalla, php

Tags: , , ,

I just quickly made a class for accessing the Gowalla API because I needed it myself. I looked for an existing class on the internet but could only find some crappy stuff on Google Code.
So I decided to make one myself.

The use of the class is fairly simple. Include the class file (don’t forget to add you API-key), make an instance and do your calls.
The class internally uses CURL to do the requests to the server and returns the data as an associative array.
I tried to document the methods enough so it’s easy to use them.

Example:

<!--?php
include('./class.gowalla.php');
$gowalla = new GowallaAPI();
$events	 = $gowalla--->getSpotEvents(846403);
foreach ($events['activity'] as $event)
{ // do stuff }
?&gt;

Feel free to download and comment.

18 Responses to “Gowalla API Class (php)”

  1. Patrick zegt:

    If the foreach loop, could you use: “echo $event->$activity_url;” to get the url?

  2. Klaas Cuvelier zegt:

    I suppose that would be:

    echo $event['activity_url'];

    Because I make an associative array from the json data, not an object. If you’d rather have an object instead of an array, remove the “true” parameter from json_decode and use:

    echo $event->activity_url;

    note, without the dollar sign in before activity_url

  3. snorpey zegt:

    Hi.
    Could you add a few more examples how to use this class?
    The example code you posted above doesn’t seem to work properly on my server (even though I added my API key)…
    Thanks!

  4. Klaas Cuvelier zegt:

    This is the code I used to test all my methods:
    http://www.cuvedev.net/wp-content/uploads/2010/05/gowalla.php.txt

    It’s pretty dirty looping and doing trial-error with the arguments, but this was the fastest to test my methods. So I’m sure my methods work.

    Another example:
    http://www.cuvedev.net/wp-content/uploads/2010/05/gowalla_example.php.txt

    I hope this helps you out.
    If you keep having problems, just let me know.

  5. snorpey zegt:

    thanks a lot for responding so quickly and providing more examples.

    i tried to implement the api class here: http://www.fishnation.de/bachelor/location-api/ajax/get-gowalla.php

    As soon as i create a new instance of the API class the script keeps seems to have connection problems (the script works fine before instantiating the API class). Right now, the code looks like this:

    Are there further requirements for the script to work? (the PHP version on my server is 5.2)

  6. Klaas Cuvelier zegt:

    And a requirement for the script is CURL, but that’s most of the time installed by default.
    Do you have error_reporting and display_errors on? So we can be sure there’s no error …

  7. snorpey zegt:

    Thanks again for helping me here…
    according to http://fishnation.de/info.php

    error_reporting = 6135 (E_ALL & ~E_NOTICE), display_errors = on, CURL is installed & enabled

    Do I have to make any changes to the class other than pasting in my API key?

  8. Klaas Cuvelier zegt:

    Weird that seems normal. It should work with only changing the apikey.
    You could send me your code (only relevant files) and I could take a look at it if you want.
    (I’m also intrigued why it doesn’t work for you)

  9. phebs zegt:

    Nice job! but somehow i get an Internal Server Error whnhe trying to download the zip, idk maybe ur hosting is having an issue right now? Thanks in advanced.

  10. Klaas Cuvelier zegt:

    @phebs, thx. Link should be working now.
    Good luck!

  11. Ellen Sundh zegt:

    Great work!! Is it possible to get stamps older than 200 from getUserStamps($userID, $limit = 20). As I understand it is a limit to 200 stamps for this call?

  12. @Ellen: I’m sorry for the (very) late reply.
    I saw that the API now allows pagination, I’ll update my script and maybe then it’ll be possible to do so.
    I’ll keep you posted!

  13. trtl zegt:

    Great! Thanks!

  14. Ellen zegt:

    Great! Thanks! I updated it aswell! Check out my experiment here:
    http://www.sundh.com/blog/2010/12/my-geo-footprint-through-gowalla/

    Do you know if there is a good library like this for Foursquare?

  15. Nice project! :-)
    Don’t now about 4square library. If I found some time, I might make it myself, but at the moment, I can’t help you out.

    Good luck with the project.

  16. Rich zegt:

    Trying to find a solid Gowalla API and continue to have time-out issues. Tried yours with fresh hope, but get the same problem. Can we chat?

  17. Rich zegt:

    Appears to be stuck in a loop. Just hangs and is over 11 minutes now… grrr

Leave a Reply