예제 #1
0
파일: notify.py 프로젝트: 0xlen/fb-notify
    def notfy(self):
        try:
            #fbconsole method
            fbconsole.AUTH_SCOPE = ['manage_notifications']
            fbconsole.authenticate()

            time.sleep(random.randint(30,120))
        
            #facebook ID
            ID = 'len.tw'
        
            #Graph API access_token

            #print fbconsole.ACCESS_TOKEN
            token = fbconsole.ACCESS_TOKEN

            req = urllib2.Request( 'https://graph.facebook.com/'+ ID + '/notifications?access_token=' + token )
            req.add_header( 'User-agent' , 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1092.0 Safari/536.6' )
            try: r = urllib2.urlopen( req )
            except urllib2.URLError:
               pass 

            jr = json.load( r ) 

            for data in jr["data"]:
                if data == '' :
                    continue
                name = data["from"]["name"]  # notify from who
                msg  = data["title"]         # notify summary
                photoID = data["from"]["id"] # Got notify from who's ID

                # Cache avatar
                photo = 'https://graph.facebook.com/' + photoID + '/picture'
                tmpPhoto = tmp + photoID
                urllib.urlretrieve(photo,tmpPhoto)

                notify(name,msg,tmpPhoto)

        # HOLD Ctrl+c event
        except KeyboardInterrupt:
            fbconsole.logout()
            print '\nLog out'
            exit(0)
예제 #2
0
파일: test.py 프로젝트: 0xlen/fb-notify
from lib import fbconsole


fbconsole.AUTH_SCOPE = ['manage_notifications']
fbconsole.authenticate()

print fbconsole.ACCESS_TOKEN