How to schedule a post on Facebook using python | Facebook SDK Tutorial

Install Python SDK:

!pip install facebook-sdk==2.0.0

Code:

import facebookdef main():   # Fill in the values noted in previous steps here    cfg = {       "page_id"      : "1xxxxx48480xxxx",  # Step 1       "access_token" : "xxxxxxxxxxxxxxxxxxxxxxxnp3QApxv12gjGnV99BNnhxxxxxxxxxx"   # Step 3        }    api = get_api(cfg)    source = "/path/to/image"    file = open(source, 'rb')    shed_time = int(time.time()+600)    print(shed_time)    status = api.put_photo(file, message = "Text message will be here",scheduled_publish_time = shed_time, published = "false",connection_name='feed')    print(status)def get_api(cfg):    graph = facebook.GraphAPI(cfg['access_token'])    resp = graph.get_object('me/accounts')    page_access_token = None    for page in resp['data']:       if page['id'] == cfg['page_id']:           page_access_token = page['access_token']    graph = facebook.GraphAPI(page_access_token)    return graphif __name__ == "__main__":   main()

How to upload photo on Facebook using python | Facebook SDK Tutorial

Install Python SDK:

!pip install facebook-sdk==2.0.0

Code:

import facebookdef main():   # Fill in the values noted in previous steps here   cfg = {      "page_id"      : "1xxxxx48480xxxx",  # Step 1      "access_token" : "xxxxxxxxxxxxxxxxxxxxxxxnp3QApxv12gjGnV99BNnhxxxxxxxxxx"   # Step 3    }    api = get_api(cfg)    source = "/path/to/image"
file = open(source, 'rb') status = api.put_photo(file, message = "Text message will be here")def get_api(cfg): graph = facebook.GraphAPI(cfg['access_token']) resp = graph.get_object('me/accounts') page_access_token = None for page in resp['data']: if page['id'] == cfg['page_id']: page_access_token = page['access_token'] graph = facebook.GraphAPI(page_access_token) return graphif __name__ == "__main__":
main()

How to write a post on Facebook using python | Facebook SDK Tutorial

Imstall Python SDK:

!pip install facebook-sdk==2.0.0

Code:

import facebookdef main():   # Fill in the values noted in previous steps here   cfg = {      "page_id"      : "1xxxxx48480xxxx",  # Step 1      "access_token" : "xxxxxxxxxxxxxxxxxxxxxxxnp3QApxv12gjGnV99BNnhxxxxxxxxxx"   # Step 3    }    api = get_api(cfg)    msg = "Hello, world!"    status = api.put_wall_post(msg)def get_api(cfg):    graph = facebook.GraphAPI(cfg['access_token'])    resp = graph.get_object('me/accounts')    page_access_token = None    for page in resp['data']:       if page['id'] == cfg['page_id']:           page_access_token = page['access_token']    graph = facebook.GraphAPI(page_access_token)    return graphif __name__ == "__main__":
main()