<s> import logging <EOL> import urllib <EOL> logger = logging . getLogger ( __name__ ) <EOL> from facebook . graph import GraphAPIError <EOL> try : <EOL> import simplejson as json <EOL> except ImportError : <EOL> try : <EOL> from django . utils import simplejson as json <EOL> except ImportError : <EOL> import json <EOL> _parse_json = lambda s : json . loads ( s ) <EOL> def get_FQL ( fql , access_token = None ) : <EOL> query = '<STR_LIT>' <EOL> params = { '<STR_LIT:q>' : fql } <EOL> if access_token : <EOL> params . update ( { '<STR_LIT>' : access_token } ) <EOL> file = urllib . urlopen ( query + urllib . urlencode ( params ) ) <EOL> raw = file . read ( ) <EOL> logger . debug ( '<STR_LIT>' % ( raw , query , fql ) ) <EOL> try : <EOL> response = _parse_json ( raw ) <EOL> finally : <EOL> file . close ( ) <EOL> if isinstance ( response , dict ) and response . get ( '<STR_LIT>' , False ) : <EOL> raise GraphAPIError ( response [ '<STR_LIT>' ] , response [ '<STR_LIT>' ] ) <EOL> return response </s>
