Facebook Graph API - upload photo using JavaScript

前端 未结 13 1320
温柔的废话
温柔的废话 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:40

    i used @Владимир Дворник code with some modification, I had the same issue and with this code it worked very well:

            var imgURL = //your external photo url
            FB.api('/photos', 'post', {
                message: 'photo description',
                access_token: your accesstoken 
                url: imgURL
            }, function (response) {
    
                if (!response || response.error) {
                    alert('Error occured:' + response);
                } else {
                    alert('Post ID: ' + response.id);
                }
    
            });
    

提交回复
热议问题