'Fetches the given path in the Graph API.
We translate args to a valid query string. If post_args is given,
we send a POST request to the given path with the given arguments.'

def request(self, path, args=None, post_args=None):

    if (not args):
        args = {}
    if self.access_token:
        if (post_args is not None):
            post_args['access_token'] = self.access_token
        else:
            args['access_token'] = self.access_token
    post_data = (None if (post_args is None) else urllib.urlencode(post_args))
    try:
        file = urllib2.urlopen(((('https://graph.facebook.com/' + path) + '?') + urllib.urlencode(args)), post_data)
    except urllib2.HTTPError as e:
        response = _parse_json(e.read())
        raise GraphAPIError(response['error']['type'], response['error']['message'])
    try:
        fileInfo = file.info()
        if (fileInfo.maintype == 'text'):
            response = _parse_json(file.read())
        elif (fileInfo.maintype == 'image'):
            mimetype = fileInfo['content-type']
            response = {'data': file.read(), 'mime-type': mimetype, 'url': file.url}
        else:
            raise GraphAPIError('Response    Error', 'Maintype    was    not    text    or    image')
    finally:
        file.close()
    if (response and isinstance(response, dict) and response.get('error')):
        raise GraphAPIError(response['error']['type'], response['error']['message'])
    return response
