大家好,我决定在facebook.com上做一个应用程序,所以我决定继续使用js sdk。

我想通过sdk添加图像作为封面图片。所以我遇到了sdk doc

我尝试过的代码。

<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<script>
var c = document.getElementById('boom');

function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);

if (response.status === 'connected') {
  // Logged into your app and Facebook.
  testAPI();
} else if (response.status === 'not_authorized') {

  document.getElementById('status').innerHTML = 'Please log ' +
    'into this app.';
} else {

  document.getElementById('status').innerHTML = 'Please log ' +
    'into Facebook.';
}


}

  function checkLoginState() {
FB.getLoginStatus(function(response) {
  statusChangeCallback(response);
});


}



  window.fbAsyncInit = function() {
  FB.init({
appId      : '289533237896176',
cookie     : true,

xfbml      : true,
version    : 'v2.1'
  });





  FB.getLoginStatus(function(response) {
statusChangeCallback(response);
  });
  };





  (function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));




  function testAPI() {
var imgURL="http://farm4.staticflickr.com/3332/3451193407_b7f047f4b4_o.jpg";

FB.api('/album_id/photos', 'post', {
message:'photo description',
url:imgURL
}, function(response){


if (!response || response.error) {
    alert('Error occured');
} else {
    alert('Post ID: ' + response.id);
}


});




}



</script>



<fb:login-button scope="public_profile,email,publish_actions" onlogin="checkLoginState();">
</fb:login-button>



<div id="status">
</div>



</body>
</html>


这段代码实际上可以正常工作..但是它不允许我将图像发布为封面照片。

谁能告诉我该怎么做..任何帮助将不胜感激..谢谢

最佳答案

您无法通过Graph API发布封面照片。

看到


https://developers.facebook.com/docs/graph-api/reference/v2.2/user/#nopublishdeleting

关于javascript - 用fb js sdk制作封面图片,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27272216/

10-09 01:33