Facebook new javascript sdk- uploading photos with it!

前端 未结 3 2111
故里飘歌
故里飘歌 2020-12-03 02:23

I am trying to upload a photo to facebook album with this javaascript code.

FB.api(\'/me/photos\', \'post\', {    access_token: GetToken(),
                          


        
3条回答
  •  旧时难觅i
    2020-12-03 02:46

    You're not far from the right query.

    first, make sure your initiating the js sdk, and requesting permissions to post.

    then, your two fields are message and URL:

    var data = array();
    data['message'] = 'hello world';
    data['url'] = 'http://google.com/moo.jpg';
    
    FB.api('/me/photos', 'post', data, function(response){
        if (!response || response.error) {
            //alert('Error occurred');
        } else {
            //alert('Post ID: ' + response.id);
        }
    }); 
    

提交回复
热议问题