Example #1
0
def get_json_graph_url(api_url):

    url = fbconsole.graph_url(api_url)
    print url
    req = requests.get(url)

    return req
Example #2
0
def download_profile_pics(friends):
    print 'downloading profile pictures...'
    for f in friends:
        picture_url = '/%s/picture' % (f['id'],)
        profile_pic = fbconsole.graph_url(picture_url)
        img_path = u'/tmp/%s.jpg' % (f['id'],)
        if os.path.exists(img_path):
            f['img_path'] = img_path
            continue
        urllib.urlretrieve(profile_pic, img_path)
        print f['first_name'], f['last_name'], f['id']
        f['img_path'] = img_path
    return friends
Example #3
0
def download_profile_pics(friends):
    print 'downloading profile pictures...'
    for f in friends:
        picture_url = '/%s/picture' % (f['id'], )
        profile_pic = fbconsole.graph_url(picture_url)
        img_path = u'/tmp/%s.jpg' % (f['id'], )
        if os.path.exists(img_path):
            f['img_path'] = img_path
            continue
        urllib.urlretrieve(profile_pic, img_path)
        print f['first_name'], f['last_name'], f['id']
        f['img_path'] = img_path
    return friends
Example #4
0
    def __init__(self, id_, name, bestScore, bestWave, time):
        self._id = id_
        self._name = name
        self._score = 0
        self._wave = 0
        self._bestScore = bestScore
        self._bestWave = bestWave
        self._bestTime = time

        self._hangar = []
        self._inventory = []    

        if self._name == None:
            result = fb.get('/me', {'fields':'name'})
            self._name = result['name']

        BytesIO = pygame.compat.get_BytesIO()
        self._profilePicture = pygame.Surface((50, 50))
        self._profilePicture.fill(Config.colors['blue'])
        profile_pic_url = fb.graph_url('/{uid}/picture'.format(uid=self._id))
        with urllib.request.urlopen(profile_pic_url) as raw_img:
            self._profilePicture = pygame.image.load(BytesIO(raw_img.read()))
import fbconsole
from fbconsole import graph_url
from urllib import urlretrieve

profile_pic = graph_url('/ralphharti/picture')  # define the person you want to have the profile pic from - Facebook name
urlretrieve(profile_pic, 'YOURFACE.jpg')
Example #6
0
# AUTHENTICATION OF USER - END
graph = facebook.GraphAPI(token) # Allows access to profile

friends = graph.get_connections(user, "friends") # Retrieves friends list

count = 0 #coutns number of facebook friends

if not os.path.exists("users/"+user+"/.friends_list.txt"):
	for friend in friends[data]: #Loops over friend list
		count += 1
		newpath = r"users/"+user+"/meta/%s" %friend['id'] #define path of where excess pics will be saved
		cgr_path = r"users/"+user+"/cgr" #defines path to where the final pics will be saved

		if not os.path.exists(newpath): #checks to see if already have path to friends' excess pics
			os.makedirs(newpath) #if not then makes it
			profile_pic = graph_url(str('/'+friend['id']+'/picture'), {"type":"large"})  # define the URL of the person's large profile picture you want to download
		 	urlretrieve(profile_pic, newpath+'/profile_picture(%s).jpg'%friend['id']) #Downloads the facebook picture and saves it 

		if not os.path.exists(cgr_path):
			os.makedirs(cgr_path) #creates path to final pics if not already there

		filename = newpath+'/profile_picture(%s).jpg'%friend['id'] #defines the variable as the friends pfilep
		print count, friend['id'], friend['name']
		img = cv2.imread(filename) 					# define test image, i.e. friends pfilep
		
		try:										# This just tests to see if the picture is viable - only isn't if there is no profile pic
			gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
			faces = face_cascade.detectMultiScale(gray, 1.3, 5)
			detects = 0 #This is for if multiple faces are detected in the profile pic
			#crop = 0
			for (x,y,w,h) in faces:
Example #7
0
         if cutnum > 0:
             clearscreens(ser)
             printitem(newsfeed, itemnum, cuts[cutnum-1], ser)
             cutnum -= 1
 if line.startswith(".e"):
     clearscreens(ser)
     num = int(line[2:])-1
     itemnum = num+newsfeedstart
     cuts = ["no"]
     cutnum = 0
     cuts.append(printitem(newsfeed, itemnum, "no", ser))
     postid = newsfeedData[itemnum]["id"]
     print "POST ID: "+postid
     #print cutNext
     userid = newsfeed["data"][itemnum]["from"]["id"]
     pictureUrl = fbconsole.graph_url("/"+userid+"/picture")
     urllib.urlretrieve(pictureUrl, "profile.jpg")
     im = Image.open("profile.jpg")
     #print im.format, im.size, im.mode
     bw = im.convert("1")
     bw.save("profile_bw.jpg")
     pix = bw.load()
     imsg = ".g"
     for x in range(0,50):
         for y in range(0,50):
             if pix[y,x] == 255:
                 imsg += "0"
             else:
                 imsg += "1"
     imsg += "\n"
     print "writing image"
t = open('.fb_access_token', 'r+b')  			# get the token retrieved by fbconcole.authenticate()
t.seek(18)
mt = mmap.mmap(t.fileno(), 0)
mt.seek(0) # reset file cursor
token_find = re.search('scope', mt)
token_end = token_find.end()
token_point = token_end - 27
token = t.read(token_point)
#print(token)

name = 'erlend.sleire'

newpath = '/Users/ralph/Desktop/' + name 
if not os.path.exists(newpath): os.makedirs(newpath)

profile_pic = graph_url('/' + name + '/picture') #Request facebook profile pic
filename = name + '.jpg'
urlretrieve(profile_pic, filename)

shutil.move('/Users/ralph/Desktop/' +filename, '/Users/ralph/Desktop/' + name )

last_activity = open('last_activity.txt' ,'w')
link = open('link.txt', 'w')

r = requests.get("https://graph.facebook.com/" + name + "/feed/" + '?access_token=' + token) 		# get the json file for the feed

raw = json.loads(r.text)
rawstr = str(raw)
a.write(rawstr)
try: 
 print(raw['data'][0]['story'])