开发者

Is it possible to publish a photo to a users feed on facebook using js?

var params = {};
params['type'] = 'photo';
params['name'] = 'Cool photo!';
params['description'] = 'Hello facebook!';
params['link'] = 'http://www.example.com';
params['picture'] = url;

FB.api('/me/photos', 'post', params, function(response) {
  if (!response || response.error) {
    console.log(response.error);
  } else 开发者_如何学Go{
    alert('Published to stream!');
  }
});

Currently returns the response '(#324) Requires upload file'. I have done some reseach and realize this is because the request requires 'multipart/form-data' for the photo data. Is there a way to do this using js?

NOTE: Yes, I want to upload a photo, full size.


I've done some experimentation with it just now, and I have also failed to manage to make a file upload using the Facebook Javascript SDK.

I also did some reading on line, and I stumbled upon this question here at stackoverflow.com: Facebook Graph API - upload photo using JavaScript

The general consensus on this that I've gathered is that it's best to use the Facebook PHP SDK or some other means, due to the multipart/form-data that you quite rightly noted.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜