# Using the Foursquare API to Check In at Remote Locations

DevFeed: [Using the Foursquare API to Check In at Remote Locations](<https://devfeed.tech/articles/how-to-make-foursquare-your-bitch-35172.md>)

Original publisher: [Read original article](<https://blog.jessfraz.com/post/how-to-make-foursquare-your-bitch/>)

Published: 2011-12-01T17:16:52Z

Content type: tutorial

Language: en

Sources: [Jessie Frazelle](<https://devfeed.tech/sources/jessie-frazelle.md>)

Topics: [API](<https://devfeed.tech/topics/api.md>), [OAuth 2.0](<https://devfeed.tech/topics/oauth2.md>), [Authentication](<https://devfeed.tech/topics/authentication.md>), [Code](<https://devfeed.tech/topics/code.md>), [cURL](<https://devfeed.tech/topics/curl.md>), [data](<https://devfeed.tech/topics/data.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [authentication](<https://devfeed.tech/tags/authentication.md>), [code](<https://devfeed.tech/tags/code.md>), [curl](<https://devfeed.tech/tags/curl.md>), [data](<https://devfeed.tech/tags/data.md>), [function](<https://devfeed.tech/tags/function.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [oauth2](<https://devfeed.tech/tags/oauth2.md>), [token](<https://devfeed.tech/tags/token.md>)

## AI overview

This tutorial explains how to authenticate an application with Foursquare, obtain an access token, retrieve venue location data, and submit check-ins through the API. It reports that repeated remote check-ins may temporarily affect badge eligibility and that large location changes require a plausible travel interval.

## Source excerpt

I would just like to preface this by saying I do not condone cheating but I thought of this as a "challenge" and not so much as "cheating". A project I am working on required me to checkin to places on foursquare that I was not currently near (or even close to). Now the answer to this was pretty simple. Checkin through the API using the lat and long of the venue I was "supposedly" at. Boom. Worked without a flaw. Ok I will admit it I am kinda a competitive person and well, the foursquare badges are so pretty I immediately started thinking about how I could check in remotely and collect them all. But surely, surely foursquare must have some sort of catches in place that do not allow this. Because I was ever so curious to find out what they may be (...and how to get around them) I decided to try. Authentication Let's start with the auth. If a user has not authed your application or is not currently logged into foursquare (assuming you created an app in the foursquare for developers dashboard) redirect them as follows. $clientId = "YOUR-CLIENT-ID"; $redirectUri = "YOUR-REDIRECT-URI"; header("Location:https://foursquare.com/oauth2/authenticate?client_id=" . $clientId ."&response_type=code&redirect_uri=" . $redirectUri); After authenticating, grab the authentication code foursquare redirected the user with. $code = $_REQUEST['code']; Now start a session and save your access token to it. This way we can easily see if the user is an authenticated app user by checking the session variable. You could also save it as a cookie if you want it to last longer. session_start(); if (!isset($_SESSION['access_token'])) { $app_token_url = "https://foursquare.com/oauth2/access_token?client_id=" . $client_id . "&amp;client_secret=" . $client_secret . "&amp;grant_type=authorization_code&amp;redirect_uri=" . $redirect_uri . "&amp;code=" . $code; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $app_token_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $foursquare_token = curl_exec($ch