开发者

Windows phone 7 and uploading photo to facebook wall

开发者 https://www.devze.com 2023-02-15 15:58 出处:网络
I am having a problem uploading a photo to a facebook wall.The post shows up on the wall, and the result returned from the apiasync call has no error, but the photo is not there :(

I am having a problem uploading a photo to a facebook wall. The post shows up on the wall, and the result returned from the apiasync call has no error, but the photo is not there :(

I am using the facebook sdk from http://facebooksdk.codeplex.com

Here is my code, any help would be appreciated!!!

  var photo = new WriteableBitmap(0, 0).FromResource("Background200x200.jpg");

  FacebookClient app = new FacebookClient();
  IDictionary<string, object> parameters = new Dictionary<string, object>();
  parameters["access_token"] = _facebookAccessTo开发者_C百科ken; //set in another method where I authenticate...
  parameters["name"] = "my picture";
  parameters["message"] = "this is a picture uploaded from my the facebook sdk";
  var mediaObject = new FacebookMediaObject {
    FileName = "Background200x200.jpg",
    ContentType = "image/jpeg",
  };
  mediaObject.SetValue(photo.ToByteArray());
  parameters["source"] = mediaObject;

  app.ApiAsync(
      UploadComplete,
      null,
      "https://graph.facebook.com/me/feed",
      parameters,
      HttpMethod.Post);


Not sure if you're still having this problem, but I'll answer to help future users if you aren't.

The problem is the way you're doing the upload. You need to first upload the picture to a photo album using the /me/photos connection (me can be replaced with the User_ID as well). Once you get the resulting PHOTO ID from the upload you can then make a subsequent call to /me/feed and post the image to the user's wall using the object_attachment parameter.

Both would be done via HTTP POST

You can reference these two documentation pages: How to upload image via the GraphAPI Graph API POST reference

Note: As of right now, the object_attachment parameter is undocumented, but works as long as you post a POST and not a STATUS MESSAGE.

0

精彩评论

暂无评论...
验证码 换一张
取 消