def get_posts(page_username): api = Api( # app_id=APP_ID, # app_secret=APP_SECRET, long_term_token=ACCESS_TOKEN, ) data = api.get_page_posts( page_id=page_username, since_time="2020-05-01", count=None, limit=100, return_json=True, ) return data
def datos(): ''' Aca estan guardados todos los datos personales necesarios que iran pasandose de una funcion a otra mediante el fluja del programa. ''' nombre_usuario = input("Por favor, ingrese su usuario: ") datos_api = Api( app_id="692001264799472", app_secret="60b272a45b500fef45f3c930d5d6d8df", long_term_token= "EAAJ1XxmSjvABAIVSXdbeDkCVQuewmUMOs8ZClysBW8NWZBMx3zGR2wN3EWZBUwjlUfSh2NF7jDztlXSALCal8VYjGZAd69wZA0xd5XUBJpB6YY3bcZC1SZBV7juZCpnBHHdc8X6ZBN1O6CjAZBt9nWPZC4BY1v0KJfRGkhpRvXjiaZA1oPS90vt6HJcRIynEvxDadJsZD", ) datos_api_sdk = facebook.GraphAPI( "EAAJ1XxmSjvABAIVSXdbeDkCVQuewmUMOs8ZClysBW8NWZBMx3zGR2wN3EWZBUwjlUfSh2NF7jDztlXSALCal8VYjGZAd69wZA0xd5XUBJpB6YY3bcZC1SZBV7juZCpnBHHdc8X6ZBN1O6CjAZBt9nWPZC4BY1v0KJfRGkhpRvXjiaZA1oPS90vt6HJcRIynEvxDadJsZD" ) crux_bot = ChatBot( "CRUX", logic_adapters=[{ 'import_path': 'chatterbot.logic.BestMatch', 'default_response': 'Disculpa, no logro entenderte. Intenta escribirlo de otra manera', 'maximum_similarity_threshold': 0.30 }]) log = open(r"C:\Users\Tomas\Documents\Tp Alg\TP2-Algoritmos\log.txt", "a") log.write("\nNueva sesion\nFecha, hora, Usuario/Crux, Mensaje\n") conexion = verificar_conexion() return nombre_usuario, datos_api, datos_api_sdk, crux_bot, log, conexion
def get_posts(page_id): # Se crea un objeto Api para la conexión, a partir del contructor, al cual se le # pasa por parámetros, las constantes anteriormente definidas. api = Api( app_id=APP_ID, app_secret=APP_SECRET, long_term_token=PAGE_ACCESS_TOKEN, ) # Se llama a un método del objeto Api, el cual nos devuelve los posteos hechos por # el usuario, en su muro. # Hay algunos filtros que se pueden pasar por parámetro, para manipular que # información se desea obtener. data = api.get_page_posts(page_id=page_id, since_time="2020-05-01", count=None, limit=100, return_json=True) return data
def main(): request = "" username = "" api = Api( app_id=APP_ID, app_secret=APP_SECRET, long_term_token=PAGE_ACCESS_TOKEN, ) igproapi = IgProApi(app_id=APP_ID, app_secret=APP_SECRET, long_term_token=PAGE_ACCESS_TOKEN, instagram_business_id=INSTAGRAM_BUSINESS_ID) graphapi = GraphAPI(access_token=PAGE_ACCESS_TOKEN) bot = bot_creation() bot_training(bot) display_options(bot) username = bot_greetings(bot) set_up_file("data\\trainer.txt", "data\\trainer.txt", True, username) bot_training(bot) request = request_input(bot, "descripcion") while request not in OPTIONS_FOR_EXIT: request = init_main_options(request, bot, api, igproapi, graphapi) else: print_response(bot, request) set_up_file("data\\trainer.bak", "data\\trainer.txt")
assert "id" in data if __name__ == "__main__": page_id = PAGE_ID user_id = USER_ID object_id = "102579945106245_118113996886173" conversation_id = "t_10224843694505732" post_id = "102579945106245_118113650219541" post_id_to_manipulate = "102579945106245_117924853571754" image = open("images\\image.jpg", "rb") api = Api( app_id = APP_ID, app_secret = APP_SECRET, long_term_token = PAGE_ACCESS_TOKEN, ) graphApi = GraphAPI( access_token = PAGE_ACCESS_TOKEN ) testGetPosts() testGetComments() testGetPageConversations() testGetConversationMessages() testPostComment() testPostPublication() testPutPublication() testDeletePublication()
from pyfacebook import Api datos = Api( app_id="692001264799472", app_secret="60b272a45b500fef45f3c930d5d6d8df", long_term_token= "EAAJ1XxmSjvABAIVSXdbeDkCVQuewmUMOs8ZClysBW8NWZBMx3zGR2wN3EWZBUwjlUfSh2NF7jDztlXSALCal8VYjGZAd69wZA0xd5XUBJpB6YY3bcZC1SZBV7juZCpnBHHdc8X6ZBN1O6CjAZBt9nWPZC4BY1v0KJfRGkhpRvXjiaZA1oPS90vt6HJcRIynEvxDadJsZD", ) def crear_post(api, page_id): argumentos_get = {"fields": "followers_count,fan_count"} peticion = api._request(path="v9.0/{0}?".format(page_id), args=argumentos_get, method="GET") data = api._parse_response(peticion) print(''' La cantidad de personas que interactuan con la pagina son {0} Followers {1} Likes en la pagina '''.format(data["followers_count"], data["fan_count"])) crear_post(datos, "341526406956810")
from pyfacebook import Api #def get_posts(page_id): datos = Api( app_id="692001264799472", app_secret="60b272a45b500fef45f3c930d5d6d8df", long_term_token= "EAAJ1XxmSjvABAGGmtcUNCyZBZAP7Yt5rMcC1q2XcFprTPGBrGqa8mOfkXN9ic4oBOx1rYjfh1fvdcekAvsrmrl1XJ3pQ4ibIlm6lT7Rif0M2jE3Rhv8n24oWUq9yG1HHDqJrK60q2Akq4NqxPdvBX4TTAtNqdJF7uYwvBLHtVbclEaYzVsZBjLtag1R4S8DRcnGh6GjcvSoHR0DGEda", ) def publicar_like( api, post_id, access_token=None, ): post_args = {"access_token": api._access_token} peticion = api._request(path="v9.0/{0}/likes".format(post_id), method="POST", post_args=post_args) data = api._parse_response(peticion) return data data = publicar_like(datos, "341526406956810_350838002692317") print(data) ''' #return data '''
import logging import arrow from pyfacebook import Api logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) FB_ACCESS_TOKEN = "1330160143827784|XNa7iu-8NuHjiHxta3PoFwD_05s" graph_api = Api(long_term_token=FB_ACCESS_TOKEN, sleep_on_rate_limit=True) def crawl_posts(page_id, since_timestamp, until_timestamp): posts = graph_api.get_page_posts(page_id=page_id, since_time=since_timestamp, until_time=until_timestamp, count=3, return_json=False) for p in posts: print((p.object_creator.name)) def crawl_comments(): comments = graph_api.get_comments_by_object_since_date( object_id='135237519825044_4152298871452202', since_date_str='2020-10-07T14:25:26.543208+06:00') for c in comments[0]: print(c.message)