Giter Club home page Giter Club logo

foursquare-api-client's Introduction

JcrollFoursquareApiClient

Build Status Total Downloads Monthly Downloads Latest Stable Version License

Find the Symfony Bundle for this library here.

Why?

There is no library currently built to interact with the foursquare api using the fantastic Guzzle HTTP Client library. Guzzle is awesome and supplies a lot of great things for building web service clients. Guzzle is fully unit tested which allows this library to be a light wrapper around the Guzzle core. You can read more about Guzzle here.

Installation

The JcrollFoursquareApiClient is available on Packagist (jcroll/foursquare-api-client) and as such installable via Composer.

If you do not use Composer, you can grab the code from GitHub, and use any PSR-4 compatible autoloader (e.g. the Symfony ClassLoader component) to load the library's classes.

Guzzle Versioning

This package is compatible with different versions of Guzzle (see below):

Guzzle Version Foursquare Client Version
~3 ~1
~4, ~5 ~2
~6 ~3

Composer example

Add JcrollFoursquareApiBundle in your composer.json:

{
    "require": {
        "jcroll/foursquare-api-client": "~3"
    }
}

Download the library:

$ php composer.phar update jcroll/foursquare-api-client

After installing, you need to require Composer's autoloader somewhere in your code:

require_once 'vendor/autoload.php';

Usage

use Jcroll\FoursquareApiClient\Client\FoursquareClient;

$client = FoursquareClient::factory([
    'client_id'     => 'your_foursquare_client_id',     // required
    'client_secret' => 'your_foursquare_client_secret', // required
    'version'       => 20140806,                        // optional
    'mode'          => 'foursquare',                    // optional (one of 'foursquare' or 'swarm')
]);

$client->setToken($oauthToken);  // optionally pass in for user specific requests

$client->setMode('swarm');       // switch from mode 'foursquare' to 'swarm'

$command = $client->getCommand('venues/search', [
    'near'  => 'Chicago, IL',
    'query' => 'sushi'
]);

$results = (array) $client->execute($command); // returns an array of results

You can find a list of the client's available commands in the bundle's client.json but basically they should be the same as the api endpoints listed in the docs.

Oauth Integration

Endpoints in the foursquare API that are user specific will require authorization with foursquare using the Oauth 2.0 protocol.

If you're using the HWIOAuthBundle with Symfony you can install the JcrollFoursquareApiBundle for automatic integration with your oauth requests.

Otherwise oauth protocol authorization is beyond the scope of this library but you can find a list of possible libraries here. After authorization you can pass the access token into the client for user specific access.

foursquare-api-client's People

Contributors

feulf avatar hpatoio avatar itavero avatar jbboehr avatar jcroll avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

foursquare-api-client's Issues

cURL error 6: Couldn't resolve host

@jcroll , I'm using your bundle for symfony.
I get an error There was an error executing the venues/explore command: cURL error 6: Couldn't resolve host 'venues' (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
Example of usage is here: jcroll/foursquare-api-bundle#8 (comment)
I've used some debuggers and realized that baseUri in Description is empty, so I added baseUri to client.json and it works, but then I've got 'missing credentials', so query parameters are not passed.
Tested on different laptops with different configuration - same result (v.3)
v2.1.1 works perfect

jcroll/foursquare-api-client v2.1.1 requires guzzlehttp/guzzle ~4|~5

Hello, I try to upgrade a projet of mine, but I can't use foursquare-api-client. Here is my error message :

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - jcroll/foursquare-api-client v2.1.1 requires guzzlehttp/guzzle ~4|~5 -> satisfiable by guzzlehttp/guzzle[4.0.0, 4.0.0-rc.1, 4.0.0-rc.2, 4.0.1, 4.0.2, 4.1.0, 4.1.1, 4.1.2, 4.1.3, 4.1.4, 4.1.5, 4.1.6, 4.1.7, 4.1.8, 4.2.0, 4.2.1, 4.2.2, 4.2.3, 4.2.4, 4.x-dev, 5.0.0, 5.0.1, 5.0.2, 5.0.3, 5.1.0, 5.2.0, 5.3.0, 5.3.1, 5.3.x-dev] but these conflict with your requirements or minimum-stability.
    - jcroll/foursquare-api-client v2.1.0 requires guzzlehttp/guzzle ~4|~5 -> satisfiable by guzzlehttp/guzzle[4.0.0, 4.0.0-rc.1, 4.0.0-rc.2, 4.0.1, 4.0.2, 4.1.0, 4.1.1, 4.1.2, 4.1.3, 4.1.4, 4.1.5, 4.1.6, 4.1.7, 4.1.8, 4.2.0, 4.2.1, 4.2.2, 4.2.3, 4.2.4, 4.x-dev, 5.0.0, 5.0.1, 5.0.2, 5.0.3, 5.1.0, 5.2.0, 5.3.0, 5.3.1, 5.3.x-dev] but these conflict with your requirements or minimum-stability.
    - Installation request for jcroll/foursquare-api-client ^2.1 -> satisfiable by jcroll/foursquare-api-client[v2.1.0, v2.1.1].

I use guzzlehttp/guzzle ^6.2, what can I do ?

403 Error

Hi,
thanks for this awsome fq api,
my web app works perfectly, but sometimes a 403 error is handled, i don't know what is the probleme, i didnt rich the limites of the api.
do you think this came from your library or it's from the original fq api ?

How to paginate results venues/search ?

Hello,

I have a problem to paginate results from venues/search. How to do that ? Is it possible ?

I use Laravel 5.1 and i would like to display pagination results in my view where I list all results find by keyword or category.

I've tried this and I have a pagination system but i don't know how to display it in my view with links according to pagination :

 $client = FoursquareClient::factory(array(
   'client_id'     => 'my_client_id',    
   'client_secret' => 'my_client_secret'
 ));

 $command = $client->getCommand('venues/search', array(
              'll' => urldecode($locat_coord),
              'query' => $keyword,
              'categoryId' => $bycat,
              'limit' => 4,
              'intent' => 'browse',
              'radius' => 20000
 ));

 $results = $command->execute(); // returns an array of results

 $paginator = new Paginator($results['response']['venues'], 2);

Thanks for your help !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.