Example #1
0
def get_mentions(screen_name, tweet_id, api, entity_uuid):
    tweets = []
    for mention in tweepy.Cursor(api.search, q=screen_name, rpp=50).items():
        if mention.in_reply_to_status_id == tweet_id:
            Comment.add_or_update(mention.id, entity_uuid, process_tweet(mention))
            tweets.append(mention)
    return tweets
def update_facebook_comments(url, entity_uuid):
    access_token = get(User, email='*****@*****.**').code
    graph = facebook.GraphAPI(access_token)
    post_response = graph.get_object('me/posts')
    comments = []
    counter = 0
    while post_response.get('paging', {}).get('next') is not None:
        for post in post_response['data']:
            if url in post.get('message', ''):
                comment_response = graph.request('{}/comments'.format(
                    post.get('id')))
                comments = comments + comment_response.get('data')
                while comment_response.get('paging',
                                           {}).get('next') is not None:
                    after = comment_response.get('paging',
                                                 {}).get('cursors',
                                                         {}).get('after')
                    comment_response = graph.request(
                        '{}/comments'.format(post.get('id')), {'after': after})
                    comments = comments + comment_response.get('data')
                link = "https://www.facebook.com/photo.php?fbid={}".format(
                    post.get('id').split('_')[0])
                comments = [
                    process_fb_comment(comment, link, graph)
                    for comment in comments
                ]
                for comment in comments:
                    Comment.add_or_update(comment.get('id'), entity_uuid,
                                          comment)
                return comments
        if counter > 10:
            return []
        post_response = requests.get(
            post_response.get('paging', {}).get('next')).json()
def get_mentions(screen_name, tweet_id, api, entity_uuid):
    tweets = []
    for mention in tweepy.Cursor(api.search, q=screen_name, rpp=50).items():
        if mention.in_reply_to_status_id == tweet_id:
            Comment.add_or_update(mention.id, entity_uuid,
                                  process_tweet(mention))
            tweets.append(mention)
    return tweets
Example #4
0
def find_all_comments():
    auth = tweepy.OAuthHandler(config.TWITTER_CONSUMER_KEY, config.TWITTER_CONSUMER_SECRET)
    api = tweepy.API(auth)
    tweets = search_twitter('kateheddleston.com', api)
    tweets = tweets + search_user_timeline('heddle317', 'kateheddleston.com', api)

    tweets = [process_tweet(tweet) for tweet in tweets]
    for tweet in tweets:
        Comment.add_or_update(tweet.get('id'), tweet.get('entity_uuid'), tweet)
    return tweets
Example #5
0
def search_twitter(url, api, entity_uuid):
    tweets = []
    for tweet in tweepy.Cursor(api.search,
                               q=url,
                               rpp=100,
                               include_entities=True,).items():
        tweet.entity_uuid = get_entity_uuid(tweet.entities.get('urls'))
        Comment.add_or_update(tweet.id, entity_uuid, process_tweet(tweet))
        tweets.append(tweet)
        tweets = tweets + get_mentions(tweet.author.screen_name, tweet.id, api, entity_uuid)
    return tweets
def find_all_comments():
    auth = tweepy.OAuthHandler(config.TWITTER_CONSUMER_KEY,
                               config.TWITTER_CONSUMER_SECRET)
    api = tweepy.API(auth)
    tweets = search_twitter('kateheddleston.com', api)
    tweets = tweets + search_user_timeline('heddle317', 'kateheddleston.com',
                                           api)

    tweets = [process_tweet(tweet) for tweet in tweets]
    for tweet in tweets:
        Comment.add_or_update(tweet.get('id'), tweet.get('entity_uuid'), tweet)
    return tweets
def search_twitter(url, api, entity_uuid):
    tweets = []
    for tweet in tweepy.Cursor(
            api.search,
            q=url,
            rpp=100,
            include_entities=True,
    ).items():
        tweet.entity_uuid = get_entity_uuid(tweet.entities.get('urls'))
        Comment.add_or_update(tweet.id, entity_uuid, process_tweet(tweet))
        tweets.append(tweet)
        tweets = tweets + get_mentions(tweet.author.screen_name, tweet.id, api,
                                       entity_uuid)
    return tweets
Example #8
0
def update_facebook_comments(url, entity_uuid):
    access_token = get(User, email='*****@*****.**').code
    graph = facebook.GraphAPI(access_token)
    post_response = graph.get_object('me/posts')
    comments = []
    counter = 0
    while post_response.get('paging', {}).get('next') is not None:
        for post in post_response['data']:
            if url in post.get('message', ''):
                comment_response = graph.request('{}/comments'.format(post.get('id')))
                comments = comments + comment_response.get('data')
                while comment_response.get('paging', {}).get('next') is not None:
                    after = comment_response.get('paging', {}).get('cursors', {}).get('after')
                    comment_response = graph.request('{}/comments'.format(post.get('id')), {'after': after})
                    comments = comments + comment_response.get('data')
                link = "https://www.facebook.com/photo.php?fbid={}".format(post.get('id').split('_')[0])
                comments = [process_fb_comment(comment, link, graph) for comment in comments]
                for comment in comments:
                    Comment.add_or_update(comment.get('id'), entity_uuid, comment)
                return comments
        if counter > 10:
            return []
        post_response = requests.get(post_response.get('paging', {}).get('next')).json()
Example #9
0
def blog_comments(uuid):
    tweets = Comment.get_comments_json(gallery_uuid=uuid, sort_by="-created_at")
    data = {"comments": tweets, "num_comments": len(tweets)}
    return json.dumps(data), 200, {"Content-Type": "application/json"}
Example #10
0
def blog_comments(uuid):
    tweets = Comment.get_comments_json(gallery_uuid=uuid,
                                       sort_by='-created_at')
    data = {'comments': tweets, 'num_comments': len(tweets)}
    return json.dumps(data), 200, {'Content-Type': 'application/json'}