Question

I am using Foursquare's v2 to allow a user to sign in to a given venue. I am trying to sign the request, but so far I am getting the following

u'meta': {
  u'errorType': u'param_error',
  u'code': 400,
  u'errorDetail': u'Invalid checkin id'
},
u'response': {

}
}

The way I am doing it is as follows, the mobile user sends a request to my webpage with the venue ID and their user id and the web handler does the following

        venueID = self.request.get("venue")
        user = self.request.get("user")
        params = {    
                  'oauth_token': user
        }
        consumer = oauth2.Consumer(key=keys.CLIENT_ID,secret=keys.CLIENT_SECRET)
        params.update({'signature': hunchMethods.sign_request(params, keys.CLIENT_SECRET)})
        check_in_req = "https://api.foursquare.com/v2/checkins/" + venueID + "?" + urllib.urlencode(params)
        print check_in_req

        url1 = fetch(check_in_req)
        json_response = simplejson.loads(url1.content.encode('utf-8')) 
        print json_response

My sign request method is as follows:

def sign_request(query_dict, data):
    queries = sorted( (unicode(k).encode('utf-8'), unicode(v).encode('utf-8'))
                      for k,v in query_dict.iteritems() )
    data = urllib.urlencode(queries) + data

UPDATE Thanks to @Drew I realised that I was trying to implement the wrong method, I have since my updated my code to be

def post(self, info):
        venueID = self.request.get("venue")
        user = self.request.get("user")
        venue = venue_id_change.retrieveNewID(venueID, user)
        url = "https://api.foursquare.com/v2/checkins/add?venueId=" +venue+ "&oauth_token=" + user + "&broadcast=private"
        logging.info(url)
        url1 = fetch(url)
        json_response = simplejson.loads(url1.content.encode('utf-8')) 

Although this does not seem to do anything :-( Am I missing something?

Was it helpful?

Solution

You seem to be using the wrong API method.

The method you're using takes a checkin ID and returns details of the existing checkin.

This one takes a venue ID and creates a new checkin.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top