用fb js sdk制作封面图片 [英] Making cover pic with fb js sdk

查看:134
本文介绍了用fb js sdk制作封面图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我已经决定在facebook上申请一个应用程序,所以我决定继续使用js sdk。



我想添加一个图片作为封面pic通过sdk.So我遇到了 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'){
//登录到您的应用和Facebook。
testAPI();
} else if(response.status ==='not_authorized'){

document.getElementById('status')。innerHTML ='请记录'+
'应用。
} else {

document.getElementById('status')。innerHTML ='请将'+
'记录在Facebook中。
}


}

函数checkLoginState(){
FB.getLoginStatus(function(response){
statusChangeCallback回应);
});


}



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。 (js,fjs);
}(document,'script','facebook-jssdk'));
fjs.parentNode.insertBefore(js,fjs);
}




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

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


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


});




}



< / script>



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



< div id =status>
< / div>



< / body>
< / html>

此代码实际上工作正常。但它不允许我将图像作为封面照片发布。 / p>

任何人都可以告诉我如何做到这一点..任何帮助将不胜感激.Thanx

解决方案

您不能通过Graph API发布封面照片。



请参阅




Hey guys i have decided to make an application in facebook.So i have decided to go on with js sdk.

I want to add an image as a cover pic via sdk.So i have came across sdk doc.

The code which i have tried.

<!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>

This code works fine actually..But it doesnt allow me to post the image as cover photo.

Can anyone tell me how to do this ..Any help would be appreciated..Thanx

解决方案

You cannot post the Cover photo via the Graph API.

See

这篇关于用fb js sdk制作封面图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆