I am getting this error while running the program below. I am running this code on CentOS. I don't know what is the problem is!
I'm stuck with this error: TypeError: put_photo() takes at most 3 arguments (4 given)
#!/usr/bin/python:
# -*- coding: utf-8 -*-
from sys import argv
#import tweepy
import facebook
def main():
cfg = {
"page_id" : "XXXX",
"access_token" : "XXXX"
}
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)
'''
caption = "இன்ரைய நாள் காட்டி #tamilcalender (©belongs to watermarked party)"
albumid = ''
with open(image.jpg,"rb") as image:
posted_image_id = graph.put_photo(image, caption, albumid) '''
return graph
if __name__ == "__main__":
main()
graph.put_photo(image, caption, albumid)has 4 arguments. It doesn't look like it, but that's because the first one is hidden, (self). You are passing 1 too many things into the method.put_photo. The object the method is attached to (graph) is automatically passed in as the first argument, traditionally calledself. Then you pass in three more yourself for a total of four. Look at the documentation or thehelp()for that method to figure out how to call it.