我是facebook整合的新手,我正在尝试使用javascript从我的应用程序上传照片到Facebook,因为2周但我现在没有找到任何解决方案。我读了facebook开发者网站但没有用。我没有'找到与javascript SDK相关的任何正确答案。如果有人可以请在javascript中转换这个PHP代码或给我一个正确的指导,将照片上传到Facebook ???????????
PHP代码在这里找到
https://developers.facebook.com/blog/post/498/
我发现下面的网站这样做,我需要在javascript中这样吗?
http://www.scrappur.com/
我在开发者网站注册并获得了APPID,SecretKey。
答案 0 :(得分:4)
乌拉........ 我找到了解决方案,
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<title>My Feed Dialog Page</title>
<g:javascript src="jquery1.7.1.js" />
</head>
<body>
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js'></script>
<p id='msg'></p>
<script type="text/javascript">
$().ready(
FB.init({appId: "you appId", status: true, cookie: true})
);
FB.login(function(response) {
if (response.authResponse) {
var access_token = FB.getAuthResponse()['accessToken'];
console.log('Access Token = '+ access_token);
FB.api('me/photos', 'post', {
message: 'has shared Picture http://www.scrappur.com/',
status: 'success',
access_token: access_token,
url: 'http://www.maargasystems.com/images/gallery/thumbs/1.jpg'
}, function (response) {
if (!response || response.error) {
alert('Error occured:' + response);
} else {
alert('Post ID: ' + response.id);
}
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {scope: 'user_photos,photo_upload,publish_stream,offline_access'});
</script>
</body>
</html>