Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7179693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:11:31+00:00 2026-05-28T17:11:31+00:00

class FourSquareTestHandler(SecurePageHandler): def get(self): logging.info(‘***********************’) logging.info(‘*****GET****’) logging.info(‘***********************’) try: request =\ urllib2.Request(‘https://api.foursquare.com/v2/users/self/checkins?oauth_token=LAF1W3VMSI0DGQYIBTNIYVIZG4VE2RFGESM45LDJRSQHFTK3&v=20120123’) data = simplejson.load(urllib2.urlopen(request))

  • 0
class FourSquareTestHandler(SecurePageHandler):
    def get(self):
    logging.info('***********************')
    logging.info('*****GET****')
    logging.info('***********************')
    try:
        request =\
                    urllib2.Request('https://api.foursquare.com/v2/users/self/checkins?oauth_token=LAF1W3VMSI0DGQYIBTNIYVIZG4VE2RFGESM45LDJRSQHFTK3&v=20120123')
        data = simplejson.load(urllib2.urlopen(request))
        logging.info('=========================')
        logging.info('*********Success*********')
        logging.info('=========================')
        logging.info(data)
        logging.info('======================================')


    except Exception:
        logging.info('**********EXCEPTION*********')
        pass

    context = {}
    return self.render_response('foursquaretest.html', **context)

Hi i wrote this code to get a users check-ins count . I manage to get a simplejson deserialized data object for me . i want to know how to access the individual element in data object because currently um getting something like this

 {
     u 'notifications': [{
         u 'item': {
             u 'unreadCount': 0
         },
         u 'type': u 'notificationTray'
     }],
     u 'meta': {
         u 'code': 200
     },
     u 'response': {
         u 'checkins': {
             u 'count': 6,
             u 'items': [{
                 u 'venue': {
                     u 'verified': False,
                     u 'name': u 'ODEL Warehouse',
                     u 'contact': {},
                     u 'location': {
                         u 'city': u 'Colombo',
                         u 'country': u 'Sri Lanka',
                         u 'postalCode': u '00600',
                         u 'state': u 'Western Province',
                         u 'address': u 'Highlevel Rd',
                         u 'lat': 6.8754399960498391,
                         u 'lng': 79.881239696240982
                     },
                     u 'stats': {
                         u 'tipCount': 2,
                         u 'checkinsCount': 76,
                         u 'usersCount': 25
                     },
                     u 'id': u '4d217410b69c6dcbf1787995',
                     u 'categories': []
                 },
                 u 'comments': {
                     u 'count': 0,
                     u 'items': []
                 },
                 u 'photos': {
                     u 'count': 0,
                     u 'items': []
                 },
                 u 'timeZone': u 'Asia/Colombo',
                 u 'type': u 'checkin',
                 u 'id': u '4f1d1940e4b0d1a657597d73',
                 u 'createdAt': 1327307072
             }, {
                 u 'venue': {
                     u 'verified': False,
                     u 'name': u 'Chesmi Consolidated',
                     u 'contact': {},
                     u 'location': {
                         u 'lat': 6.8783062620154825,
                         u 'city': u 'colombo 5',
                         u 'lng': 79.879610192565167,
                         u 'country': u 'Sri Lanka',
                         u 'address': u '21, Siebel Avenue,'
                     },
                     u 'stats': {
                         u 'tipCount': 0,
                         u 'checkinsCount': 2,
                         u 'usersCount': 2
                     },
                     u 'id': u '4ed4cab6e5fa7b1a923b1e1e',
                     u 'categories': []
                 },
                 u 'comments': {
                     u 'count': 0,
                     u 'items': []
                 },
                 u 'photos': {
                     u 'count': 0,
                     u 'items': []
                 },
                 u 'timeZone': u 'Asia/Colombo',
                 u 'type': u 'checkin',
                 u 'id': u '4f1d1920e4b0e6badd487a53',
                 u 'createdAt': 1327307040
             }, {
                 u 'venue': {
                     u 'verified': False,
                     u 'name': u 'Commercial Bank',
                     u 'contact': {},
                     u 'location': {
                         u 'city': u 'Colombo 5',
                         u 'country': u 'Sri Lanka',
                         u 'postalCode': u '00500',
                         u 'state': u 'Western Province',
                         u 'address': u 'High Level Rd',
                         u 'lat': 6.8776848396168955,
                         u 'lng': 79.879610192565167
                     },
                     u 'stats': {
                         u 'tipCount': 0,
                         u 'checkinsCount': 42,
                         u 'usersCount': 9
                     },
                     u 'id': u '4c85bdb1d4e237047aaf8588',
                     u 'categories': [{
                         u 'pluralName': u 'Banks',
                         u 'primary': True,
                         u 'name': u 'Bank',
                         u 'shortName': u 'Bank / Financial',
                         u 'id': u '4bf58dd8d48988d10a951735',
                         u 'icon': {
                             u 'prefix': u 'https://foursquare.com/img/categories/shops/financial_',
                             u 'name': u '.png',
                             u 'sizes': [32, 44, 64, 88, 256]
                         }
                     }]
                 },
                 u 'comments': {
                     u 'count': 0,
                     u 'items': []
                 },
                 u 'photos': {
                     u 'count': 0,
                     u 'items': []
                 },
                 u 'timeZone': u 'Asia/Colombo',
                 u 'type': u 'checkin',
                 u 'id': u '4f1d18f5e4b0e6badd485953',
                 u 'createdAt': 1327306997
             }, {
                 u 'venue': {
                     u 'verified': False,
                     u 'name': u 'Siebel Avenue Bus Stop 138',
                     u 'contact': {},
                     u 'location': {
                         u 'lat': 6.8775550799999996,
                         u 'country': u 'Sri Lanka',
                         u 'lng': 79.879341159999996
                     },
                     u 'stats': {
                         u 'tipCount': 3,
                         u 'checkinsCount': 76,
                         u 'usersCount': 15
                     },
                     u 'id': u '4e5c53b345dd045aab4d7dfa',
                     u 'categories': [{
                         u 'pluralName': u 'Bus Stations',
                         u 'primary': True,
                         u 'name': u 'Bus Station',
                         u 'shortName': u 'Bus Station',
                         u 'id': u '4bf58dd8d48988d1fe931735',
                         u 'icon': {
                             u 'prefix': u 'https://foursquare.com/img/categories/travel/busstation_',
                             u 'name': u '.png',
                             u 'sizes': [32, 44, 64, 88, 256]
                         }
                     }]
                 },
                 u 'comments': {
                     u 'count': 0,
                     u 'items': []
                 },
                 u 'photos': {
                     u 'count': 0,
                     u 'items': []
                 },
                 u 'timeZone': u 'Asia/Colombo',
                 u 'type': u 'checkin',
                 u 'id': u '4f1d18e1e4b0e2eeed04eff2',
                 u 'createdAt': 1327306977
             }, {
                 u 'venue': {
                     u 'verified': False,
                     u 'name': u 'Visni',
                     u 'contact': {},
                     u 'location': {
                         u 'lat': 6.8785901069641113,
                         u 'country': u 'Sri Lanka',
                         u 'lng': 79.879791259765625
                     },
                     u 'stats': {
                         u 'tipCount': 1,
                         u 'checkinsCount': 8,
                         u 'usersCount': 1
                     },
                     u 'id': u '4eb75312f5b94bd85c9fa375',
                     u 'categories': [{
                         u 'pluralName': u 'Tech Startups',
                         u 'primary': True,
                         u 'name': u 'Tech Startup',
                         u 'shortName': u 'Tech Startup',
                         u 'id': u '4bf58dd8d48988d125941735',
                         u 'icon': {
                             u 'prefix': u 'https://foursquare.com/img/categories/shops/technology_',
                             u 'name': u '.png',
                             u 'sizes': [32, 44, 64, 88, 256]
                         }
                     }]
                 },
                 u 'comments': {
                     u 'count': 0,
                     u 'items': []
                 },
                 u 'photos': {
                     u 'count': 0,
                     u 'items': []
                 },
                 u 'timeZone': u 'Asia/Colombo',
                 u 'type': u 'checkin',
                 u 'id': u '4f1d18cde4b0850c85e124d1',
                 u 'createdAt': 1327306957
             }, {
                 u 'venue': {
                     u 'verified': False,
                     u 'name': u 'Calcey Technologies',
                     u 'contact': {
                         u 'phone': u '0112827560',
                         u 'formattedPhone': u '011 2 827560'
                     },
                     u 'location': {
                         u 'city': u 'Colombo 5',
                         u 'country': u 'Sri Lanka',
                         u 'postalCode': u '00500',
                         u 'state': u 'Sri Lanka',
                         u 'crossStreet': u 'Highlevel Rd',
                         u 'address': u '21 Siebel Ave',
                         u 'lat': 6.8782598000000004,
                         u 'lng': 79.879707733333333
                     },
                     u 'stats': {
                         u 'tipCount': 0,
                         u 'checkinsCount': 324,
                         u 'usersCount': 14
                     },
                     u 'id': u '4c43efd62d3ec9b60e3f2eae',
                     u 'categories': [{
                         u 'pluralName': u 'Tech Startups',
                         u 'primary': True,
                         u 'name': u 'Tech Startup',
                         u 'shortName': u 'Tech Startup',
                         u 'id': u '4bf58dd8d48988d125941735',
                         u 'icon': {
                             u 'prefix': u 'https://foursquare.com/img/categories/shops/technology_',
                             u 'name': u '.png',
                             u 'sizes': [32, 44, 64, 88, 256]
                         }
                     }]
                 },
                 u 'comments': {
                     u 'count': 0,
                     u 'items': []
                 },
                 u 'photos': {
                     u 'count': 0,
                     u 'items': []
                 },
                 u 'timeZone': u 'Asia/Colombo',
                 u 'type': u 'checkin',
                 u 'id': u '4f1d18a3e4b0a6271ab6c175',
                 u 'createdAt': 1327306915
             }]
         }
     }
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:11:31+00:00Added an answer on May 28, 2026 at 5:11 pm

    Your data is a python dictionary object.

    It has nested dictionaries and lists inside.

    for e.g.,

    >>> data['notifications']
    [{u'item': {u'unreadCount': 0}, u'type': u'notificationTray'}]
    
    >>> data['notifications']['item']['unreadCount']
    0
    
    >>> data['response']['checkins']['count']
    6
    
    >>> data['response']['checkins']['items'][0]
        {u'comments': {u'count': 0, u'items': []},
         u'createdAt': 1327307072,
         u'id': u'4f1d1940e4b0d1a657597d73',
         u'photos': {u'count': 0, u'items': []},
         u'timeZone': u'Asia/Colombo',
         u'type': u'checkin',
         u'venue': {u'categories': [],
                    u'contact': {},
                    u'id': u'4d217410b69c6dcbf1787995',
                    u'location': {u'address': u'Highlevel Rd',
                                  u'city': u'Colombo',
                                 u'country': u'Sri Lanka',
                                  u'lat': 6.8754399960498391,
                                  u'lng': 79.881239696240982,
                                  u'postalCode': u'00600',
                                  u'state': u'Western Province'},
                    u'name': u'ODEL Warehouse',
                    u'stats': {u'checkinsCount': 76,
                               u'tipCount': 2,
                               u'usersCount': 25},
                    u'verified': False}}
    

    This shows there are 6 (checkin)entries. So to get id of first (0th list item) checkin,

    >>> data['response']['checkins']['items'][0]['id']
    u'4f1d1940e4b0d1a657597d73'
    

    To get the first comment(content of it),

    >>> data['response']['checkins']['items'][0]['comments']['items'][0]
    

    and similar for other fields.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

class Ball: a = [] def __init__(self): pass def add(self,thing): self.a.append(thing) def size(self): print
class ITestType(object): Sample interface type __metaclass__ = ABCMeta @abstractmethod def requiredCall(self): return class TestType1(object):
class Anketum < ActiveRecord::Base has_one :user class << self def search(params) self.scope :h, :conditions
class MyClass(object): def __init__(self): self._my_secret_thing = 1 def _i_get(self): return self._my_secret_thing def _i_set(self, value):
class test: def __init__(self, val): self.val = val self.val.lower() Why doesn't lower() operate on
class CreateMatches < ActiveRecord::Migration def self.up create_table :matches do |t| t.integer :result_home t.integer :result_away
class Api::StoresController < ApplicationController respond_to :json def index @stores = Store.all(:include => :products) respond_with
class Package: def __init__(self): self.files = [] # ... def __del__(self): for file in
class Product < ActiveRecord::Base set_table_name 'produce' end module ActiveRecord class Base def self.set_table_name name
class ToBeDeleted: def __init__(self, value): self.value = val # Whatever... def __del__(self): print self.value

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.