简体   繁体   中英

How to upload a photo to facebook wall using graph api

I am using graph api for uploading the photo.

I want to upload the picture to wall of user. I can't paste my local pc image to it.So Need to create first album and add image into it.

I am able to create an album.But I am getting an error on putting photo to an album. Error is OAuthException", "message": "(#324) .

Here is my url.I am doing in C#.net

https://graph.facebook.com/album_id/photos?access_token=generated access token&method=post&picture=D:\foldername\Image\flower.jpg&message=flower

You have to put @ in front of the file path, so it knows you're referencing to a file. And yes, you're doing it the right way. The Graph API supports only local file upload.

It hard to give a concrete solution without the context though..

First look at the example from facebook . Note that image parameter name is source (not picture as in your url).

Second look at this question in second answer you will find method that help you to send image.

Just use it something like this:

NameValueCollection nvc = new NameValueCollection();    
nvc.Add("access_token", "GENERATED TOKEN");    
nvc.Add("message", "MESSAGE TO SEND");    
HttpUploadFile("https://graph.facebook.com/album_id/photos",          
@"D:\foldername\Image\flower.jpg", "source", "image/jpeg", nvc);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM