0

I have made a simple link which checks in a predefined venue in foursquare. I am using the foursquare api: https://api.foursquare.com/v2/checkins/add. I passed the required parameters but the problem is that after check in, the response of the http post request is displayed to the user. I want the user to be redirected to m.foursquare.com

I have implemented it in a mobile website.

    <form id="frm1" action="https://api.foursquare.com/v2/checkins/add" method="post">
    <input type="hidden" name="venueId" value="50add32f29a67a495fca09c1"><br>
    <input type="hidden" name="shout" value="I am watching Black Cat at Chinese     Multiplex"><br>
    <input type="hidden" id="token" name="oauth_token"><br>
    <input type="hidden" name="v" value="20121122"><br>

Then I am setting the access token value as:

       document.getElementById("token").value=at;

Then I submit the form

    document.getElementById("frm1").submit();

I am extracting the access token from url by some code...and it is getting passed in the request and even the checkin is successful but the response is displayed which is not desired.As the response looks like a javascript object containing elements like meta, notifications etc.So please suggest a method to bypass the response and go to the foursquare homepage.

1 Answers1

0

You cannot do this in JavaScript alone.

As Foursquare expects a POST request to their API, you cannot use JSONP or any other x-browser technology to circumvent the Same Origin Policy.

Furthermore, as Foursquare's API does not seem to support any redirect parameter, you have no other option except to make the API call on your server, on your clients behalf, wait for the response, and then redirect them afterwards.

Community
  • 1
  • 1
Matt
  • 74,352
  • 26
  • 153
  • 180