1

I'm having a problem getting a picture in facebook. I'm using python plus facebook graph api. I research getting or how to download a picture in facebook so here's what i got.

import os
import json
import urllib
import pprint

ACCESS_TOKEN = 'ACCESS_TOKEN_SAMPLE'

host = "https://graph.facebook.com/v2.8"
path = "/me?fields=id,name,picture"
params = urllib.urlencode({"access_token": ACCESS_TOKEN})

url = "{host}{path}?{params}".format(host=host, path=path, params=params)

resp = urllib.urlopen(url).read()

getDATA = json.loads(resp)

os.system("echo " + str(getDATA) | tee >log.txt)

I tried to understand it but I'm having an error running this. Here's the error i got:

{uerror: {umessage: uAn active access token must be used to query information about the current user., ucode: 2500, utype: uOAuthException, ufbtrace_id: uGLoKMknFrR1}}

Also I'm trying to put the downloaded data to a log file. I need an output which has like a downloading progress or bar? Like when you run a speedtest in a terminal it shows the size of the data that it downloads.

Karl Guevarra
  • 349
  • 2
  • 12
  • are you sure the access token you are using is the right one? – S Raghav Feb 04 '17 at 13:19
  • @raghav710 yes I'm sure it is the right. – Karl Guevarra Feb 04 '17 at 13:49
  • 1
    can you print the value of url? I think you should put an `&` between `{path}` and `{params}` rather than `?`, since there is already a `?` in the URL. refer [here](http://stackoverflow.com/questions/31353572/an-active-access-token-must-be-used-to-query-information-about-the-current-user) – S Raghav Feb 04 '17 at 15:04

0 Answers0