1

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
Swati
  • 61
  • 2
  • 9
  • i think the problem that you trying to send PATH of the image on your computer, not image itself, please provide some source code – Alexander Jun 30 '11 at 07:18
  • I can't paste the code.Is there way to post image instead of path. – Swati Jun 30 '11 at 07:25
  • Not familiar with the API but common sense tells me that the value of `picture` should be the URL of valid picture e.g. `sURL = "https://graph.facebook.com/album_id/photos?access_token=generated access token&method=post&picture=" + Server.UrlEncode("http://www.somesite.com/flower.jpg") + "&message=flower";` – Shadow The GPT Wizard Jun 30 '11 at 07:45

2 Answers2

0

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.

Observator
  • 34
  • 2
  • According to Shadow and Observator,I have done but still have same error.I know there is function called filupload=>true.But that is php function ,how to deals with C#.net – Swati Jun 30 '11 at 08:08
  • @ character mean that string is verbatim, not that is "file referecnce", [look c# specification](http://msdn.microsoft.com/en-us/library/aa691090(v=vs.71).aspx) – Alexander Jun 30 '11 at 08:08
  • I'm sorry, I've somehow overlooked that it's C# we're talking about. If i stumble upon any examples, I'll be sure to post them here. Also, the @ in PHP is by default used to supress error messages, but the Graph API uses it to reference a local file. – Observator Jun 30 '11 at 08:29
0

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);
Community
  • 1
  • 1
Alexander
  • 1,287
  • 1
  • 15
  • 34
  • 1
    Does I need to define method HttpUploadFile() or it is inbuild method we just need to call it.If yes what namespace does it required? – Swati Jun 30 '11 at 09:38
  • i have provided link to question about uploading files, look at second answer, code of method is the there – Alexander Jun 30 '11 at 14:39
  • Hi Alexander,thank for your hepl.I will try ,if problem occure ,ask you. – Swati Jul 01 '11 at 04:48
  • Hi Alexander,I am still Having a problem.I tried that code.Now I am moving my direction.The thing is first have to create an album then add photo to that album.Then pass a link or use picture or source attribute to post on user wall.I am getting an error when I am trying to send that .The error is "message": "(#100) FBCDN image is not allowed in stream. – Swati Jul 06 '11 at 11:48
  • unfortunatelly facebook doesn't allow to post images from fbcdn.net(it's where photos from album stored), it's weird but that the true( the only way you can send picture to wall is upload it to some picture(or may be you own) hosting, and then provide link for image from that hosting – Alexander Jul 07 '11 at 01:05
  • Thanks Alexander.I think you are right.I don't see any other way.It is best to host own server.And used that link.Then I am able to do it.I know how to post picture to wall.Thanks for your help. – Swati Jul 07 '11 at 04:43
  • Hi Alexander,Sorry for disturb you.I posted this question but not received the correct answer that's why asking you.Do you have any idea about iframe?I want to add iframe to my facebook page.I read FBML that deprecated one.I am using C#.net for my project.Does I need to installed javascript sdk to do that. – Swati Jul 07 '11 at 06:12
  • I recommend you do not use deprecated api. Better to follow recomendations from facebook team and use JavaScript SDK, you do not need to install it, just reference it in header of you page, more info is [here](http://developers.facebook.com/docs/reference/javascript/) – Alexander Jul 07 '11 at 06:35