I am using facebook API (version 3.1.) to publish automatically on my Facebook feed using a python script (shown below), which was working fine until recently. I found that facebook deprecated the put_photo function from the new api version (8.0), but can't find how to call the new function or new method to publish photos automatically from the python script. So, Is there a new way to do this? What am I missing?

Thanks a lot for the help!

import facebook
import sys,os
import json
import numpy as np

def facebook_post_sentido(figure_name):

    def get_cfg():

        cfg = {
        "page_id"      : "my_id"
        "access_token" : "my_token"
        }

        return cfg

    def gen_api(cfg):

        API = facebook.GraphAPI(cfg['access_token'])
        print("generating api connection")
        return API

    cfg = get_cfg()
    API = gen_api(cfg)
    photo_id = API.put_photo(image=open(figure_name, 'rb'), )
    # API.put_object(parent_object=cfg["page_id"], connection_name="feed", 
    #               message="SISMO SENTIDO RELOCALIZADO", 
    #               attached_media=json.dumps([{'media_fbid': str(photo_id.get('id', ''))}]))

facebook_post_sentido(figure_name="myfigure")

When I run the code I get the following error:

facebook.GraphAPIError: (#200) This endpoint is deprecated since the required permission publish_actions is deprecated

1

There are 1 answers

0
04FS On

There is no way to post a photo onto user profiles via API any more.

This has been completely removed, same as making normal posts via API. With the exception of live videos, you can not publish anything any more onto user profiles via API.

Apps wanting to provide sharing functionality to end users, can use one of the dialogs provided. (But even those don’t allow a photo upload, you can only share links.)