简体   繁体   English

如何使用图形 api 将照片上传到 facebook 墙上

[英]How to upload a photo to facebook wall using graph api

I am using graph api for uploading the photo.我正在使用图 api 上传照片。

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) . Error is OAuthException", "message": "(#324)

Here is my url.I am doing in C#.net这是我的 url。我在 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. Graph API 仅支持本地文件上传。

It hard to give a concrete solution without the context though..但是,如果没有上下文,很难给出具体的解决方案..

First look at the example from facebook .首先看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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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