0

我是 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。

4

1 回答 1

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>
于 2012-05-01T09:37:52.253 回答