I use Foursquare v2 so that the user can log in to this place. I am trying to sign a 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': { } }
How do I do this, the mobile user sends a request to my web page 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 subscription 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 realized that I was trying to implement the wrong method since I updated my code
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 nothing :-( Am I missing something?
source share