facebook-sdk
facebook-sdk copied to clipboard
Add a file parameter of put_object for uploading images
It was related to #360.
A number of commit messages have been modified.
Usage
graph.put_object(
parent_object='post_id',
connection_name='comments',
message='Second!',
file=open('image.jpg', 'rb'))
@martey
long time no see. I will try to solve the problem asap.
Sorry I'm late.
Facebook has disabled likes and comments through graph API.
So, I cannot test my pull request more. How do we do?
If liking and/or commenting are no longer possible, don't worry about testing them.
Hello, How's it going?
I tested to upload video object on the post using this code. however it was not working. because videos must be published to graph-video.facebook.com
instead of graph.facebook.com
(ref. https://developers.facebook.com/docs/graph-api/video-uploads)
So, I think this PR is only valid for uploading images now.
To upload the video, we should do like this example.
import requests
_user_id = '' # user id (ex. 1603333222111000)
_token = '' # Graph User API Token
url = 'https://graph-video.facebook.com/{user_id}/videos?access_token={token}'.format(
user_id=_user_id
token=_token
)
files = {
'file': open('movie.mp4', 'rb')
}
response = requests.post(url, files=files).text
print(response)
Hello,
I'm using python, and also using this function to send messages:
graph.put_object(txt_id, "messages", message = 'Message goes here')
How can I send a attachment or a photo?
Hello,
I'm using python, and also using this function to send messages:
graph.put_object(txt_id, "messages", message = 'Message goes here')
How can I send a attachment or a photo?
graph.put_object(txt.id, "messages", message='Message goes here', source='url of the photo', link='any link you want to attach')
But how to attach files from local pc i still dont know