get logged in user data using facebook api in python and store in mongo database
<p>i have already developed a FB app.now,i am trying to harvest the user data and store it into the database.But, one thing i am not understanding is how to store the data of the logged in user in mongo db using graph api? prior to that how to fetch data in python?
I know this is repetitive but,i am not able to clear my concept of how to use the api in python.
i have tried this:</p>

<pre><code>#!/usr/bin/env python
# encoding: utf-8
import json
import urllib2
import re
def getdata(id):
'''Queries the Facebook API for the specific group ID, and populates the
results dictionary with the Group ID, User Name, and User ID'''
#An access token is now required for quering the group messages.
a_token='access_token=&lt;access token&gt;'
urlquery='https://graph.facebook.com/'+id+'/feed&amp;limit=20?access_token='+ a_token +''
print urlquery
data=json.load(urllib2.urlopen(urlquery))
harvest = []
results = {}    
for item in data['data']:
    try:
        results = {}
        results['grpid'] = id
        user = item['from']
        results['uname'] = user['name']
        results['uid'] = user['id']
        harvest.append(results)
    except:
        pass

print len(harvest)
def getgrpids():
        urlquery='https://graph.facebook.com/&lt;any username&gt;'#can i put my app name?
                             #not clear from examples given on facebook graph api page.
        data=json.load(urllib2.urlopen(urlquery))
    ids=[]
    for item in data['data']:
    try:
        ids.append(item['id'])
    except:
        pass
return ids

def main():
    idres=getgrpids()
    for id in idres:
    #Loops through all of the group ids returned by getgrpids()
        print 'Group ID:', id 
        getdata(id) 

if __name__ == '__main__':
    main()
</code></pre>

<p>Now the problem goes like this.When i change the username to some other the error report says that the user should be logged in or the app cannot get the user details.I am not understanding this since my friend was online at that time still the error?
Am i missing something?secondly i am not able to put my APP NAME IN THE QUERY (see the comment). Somebody please help.</p>

<p>thanks,</p>
