Reputation: 518
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()
Upvotes: 0
Views: 45
Reputation: 4196
put_photo
API takes only two arguments.
image
- A file object representing the image to be uploaded.album_path
- A path representing where the image should be uploaded. Defaults to /me/photos which creates/uses a custom album for each Facebook application.Please check this link for more info.
You are passing three aruguments - image, caption, albumid
.
Along with these three, as explained in above comments by @kindall and @BrandonIbbotson, the one mandatory argument is passed which is related to self
.
Just check above link for examples and just pass two valid arguments.
Upvotes: 1