Beispiel #1
0
def fb_fetch_post(pagename, since, until):
    url = fb_gen_url(
        node=fb_name_to_id(pagename) + '/posts',
        fields='id,message,link,name,type,shares,created_time,\
                reactions.limit(0).summary(true),\
                comments.limit(0).summary(true)',
        since=since,
        until=until,
        limit=50,
        access_token=ACCESS_TOKEN
    )

    isnext = True
    # data = []

    while isnext is True:
        json_result = jr.json_request(url=url)

        paging = None if json_result is None else json_result.get('paging')
        posts = None if json_result is None else json_result.get('data')

        url = None if paging is None else paging.get('next')
        isnext = url is not None

        # data += posts

    # return data
        yield posts
import sys
from datetime import datetime
from analysis_fb.collection.api import json_request as jr

url = 'http://192.168.1.38:8088/mysite3/api/guestbook/list'


def success_fetch_guestbook_list(response):
    print(response)


def error_fetch_guestbook_list(e):
    print('%s : %s' % (e, datetime.now()), file=sys.stderr)


"""
jr.json_request(
    url=url,
    success=success_fetch_guestbook_list,
    error=error_fetch_guestbook_list)
"""

json_result = jr.json_request(url=url)
print(json_result)
Beispiel #3
0
def fb_name_to_id(pagename):
    url = fb_gen_url(node=pagename, access_token=ACCESS_TOKEN)
    print(url)
    json_result = jr.json_request(url)
    print(json_result)
    return json_result.get('id')
import sys
from datetime import datetime
from analysis_fb.collection.api import json_request as jr

url = "http://192.168.1.30:8080/mysite3/guestbook/api/list"


def success_fetch_guestbook_list(response):
    print(response)


def error_fetch_guestbook_list(e):
    print('%s : %s' % (e, datetime.now()), file=sys.stderr)


jr.json_request(url=url, success=success_fetch_guestbook_list)
"""
json_result = jr.json_request(url=url)

print(json_result)
"""