def initialize_facebook_graph_api(self):
        fa = FacebookAuthenticator()
        self.access_token = fa.get_saved_access_token()

        try:
            self.graphFBAPI = GraphAPI(self.access_token)
        except exceptions.OAuthError:
            self.access_token = fa.get_new_access_token()
            self.graphFBAPI = GraphAPI(self.access_token)

        print "** Facebook Crawler is using App Access Token: " + self.access_token + " **"
示例#2
0
        #if locale == "BR":
        #    print "[>] Locale is BR (place mentioned)"
        #    return "BR"
        #elif locale == "UNKNOWN":
        locale = self.detect_portuguese_language(response)
        if locale == "BR":
            print "[>] Locale is BR (portuguese language detection)"
            return "BR"
        elif locale == "UNKNOWN":
            print "[>] Locale is UNKNOWN. This feed will be skipped and its posts will never be saved."
            return "UNKNOWN"
        #else:
        #    print "[!] No locale. (?)"
        #    exit()


if __name__ == '__main__':
    ff = FeedFilter(ElasticBridge())

    fa = FacebookAuthenticator()
    access_token = fa.get_saved_access_token()
    graphFBAPI = GraphAPI(access_token)
    print "** Facebook Crawler is using App Access Token: " + access_token + " **"

    slow_feeds = ["570693256352787", "859054397469912", "635580286574784", "571240006244349"]

    for feed in slow_feeds:
        response = graphFBAPI.get(feed + "/links")
        print ff.detect_locale(False, response)