def fb_name_to_ig_id(pagename): url = fb_generate_url(node=pagename, fields='id, name, accounts', access_token=ACCESS_TOKEN) json_result = jr.json_request(url) page_id = json_result['accounts']['data'][0]['id'] #페이스북 페이지 아이디 url = fb_generate_url(node=page_id, fields='instagram_business_account', access_token=ACCESS_TOKEN) json_result = jr.json_request(url) return json_result['instagram_business_account']['id'] #인스타그램 아이디 리턴
def ig_media(id): url = fb_generate_url( node=id, fields= 'id,caption,comments_count,like_count,media_type,media_url,owner,permalink,shortcode,timestamp,username,children,comments', access_token=ACCESS_TOKEN) json_result = jr.json_request(url) return json_result
def ig_basic_info(pagename, since, until): url = fb_generate_url( node=pagename, fields= 'biography,followers_count,follows_count,ig_id,id,media_count,name,profile_picture_url,username,recently_searched_hashtags,stories,tags', since=since, # 시작 날짜 until=until, # 끝 날짜 limit=30, # 개수 access_token=ACCESS_TOKEN) json_result = jr.json_request(url) return json_result
def fb_fetch_post(pagename, since, until): url = fb_generate_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 = 30, access_token = ACCESS_TOKEN ) isnext = True while isnext is True: json_result = jr.json_request(url) paging = None if json_result is None else json_result.get('paging') url = None if paging is None else paging.get('next') isnext = url is not nont posts = None if json_result is None else json_result.get('data') yield posts json_result = jr.json_request(url) return json_result
def fb_fetch_post(pagename, since, until): # URL 생성 시, 여러 파라미터를 전달 url = fb_generate_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=30, # 개수 access_token=ACCESS_TOKEN) # print(url) json_result = jr.json_request(url) return json_result
def ig_media_list(pagename, since, until): url = fb_generate_url( node=pagename, fields='media', since=since, # 시작 날짜 until=until, # 끝 날짜 limit=30, # 개수 access_token=ACCESS_TOKEN) isnext = True while isnext is True: json_result = jr.json_request(url) try: paging = None if json_result is None else json_result['media'][ 'paging'] url = paging['next'] except KeyError: url = None isnext = url is not None posts = None if json_result is None else json_result['media']['data'] # generator를 사용해서 fb_fetch_post(...) 함수를 for 푸르안에서 사용 가능하도록 수정한다. yield posts
def fb_fetch_post(pagename, since, until): url = fb_generate_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 = 30, # 개수 access_token = ACCESS_TOKEN ) isnext = True while isnext is True: json_result = jr.json_request(url) paging = None if json_result is None else json_result.get('paging') url = None if paging is None else paging.get('next') isnext = url is not None posts = None if json_result is None else json_result.get('data') # generator를 사용해서 fb_fetch_post(...) 함수를 for 푸르안에서 사용 가능하도록 수정한다. yield posts
def fb_name_to_id(pagename): url = fb_generate_url(node = pagename, access_token = ACCESS_TOKEN) # print(url) json_result = jr.json_request(url) # print(json_result) # {'name': 'JTBC 뉴스', 'id': '240263402699918'} return json_result.get('id')
def fb_name_to_id(pagename): url = fb_generate_url(node = pagename, access_token = ACCESS_TOKEN) json_result = jr.json_request(url) return json_result.get('id')