Facebook Graph API - upload photo using JavaScript

前端 未结 13 1270
温柔的废话
温柔的废话 2020-11-27 11:03

Is it possible to upload a file using the Facebook Graph API using javascript, I feel like I\'m close. I\'m using the following JavaScript

var params = {};
         


        
相关标签:
13条回答
  • 2020-11-27 11:47

    To upload a file from the local computer with just Javascript try HelloJS

    <form onsubmit="upload();">
         <input type="file" name="file"/>
         <button type="submit">Submit</button>
    </form>
    
    <script>
    function upload(){
       hello.api("facebook:/me/photos", 'post', document.getElementById('form'), function(r){
          alert(r&&!r.error?'Success':'Failed'); 
       });
    }
    </script>
    

    There's an upload demo at http://adodson.com/hello.js/demos/upload.html

    0 讨论(0)
提交回复
热议问题