def __init__(self): self.appID = config.get('Facebook', 'Application ID') self.apiKEY = config.get('Facebook', 'API Key') self.apiSEC = config.get('Facebook', 'API Secret') self.pageUID = config.get('Facebook', 'Page UID') log.write('Fetching token from Facebook:') self.token = self.get_token() log.write(self.token)
def fetch_site(self): try: connection = urllib2.urlopen(self.address) raw_page = connection.read() uraw_page = unicode(raw_page, 'windows-1250') log.write('Size: ' + str(len(uraw_page) / 1024) + '.' + str(len(uraw_page) % 1024) + ' kB') except Exception, e: log.write(str(e))
def publish_link(self, story): datastream = urllib2.urlopen('https://api.facebook.com/method/stream.publish?message=' + story[0].encode('utf-8', 'replace').replace(' ', '%20') + '%0A' + story[1].encode('utf-8', 'replace').replace(' ', '%20') + '&action_links=[{"text":"Link","href":"' + story[3].encode('utf-8', 'replace') + '"}]&uid=' + self.pageUID + '&' + self.token) log.write('New post published')
def publish(self, story): datastream = urllib2.urlopen('https://api.facebook.com/method/stream.publish?message=' + story[0].encode('utf-8', 'replace').replace(' ', '%20') + '%0A' + story[1].encode('utf-8', 'replace').replace(' ', '%20') + '&uid=' + self.pageUID + '&' + self.token) log.write('New post published')