Facebook Graph API - upload photo using JavaScript

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

    Photos can be uploaded to facebook profile using Ajax as follows.

    $.ajax({
                type: "POST",
                url: "https://graph.facebook.com/me/photos",
                data: {
                    message: "Your Msg Goes Here",
                    url: "http://www.knoje.com/images/photo.jpg[Replace with yours]",
                    access_token: token,
                    format: "json"
                },
                success: function(data){
                   alert("POST SUCCESSFUL"); }
                });
    

    So this is the best way to post photo to a facebook profile with GRAPH API and is the simple one.

    In many answer i have seen that image url is shwon by the source,picture or image etc but that doesn't works.

    The use of of source,picture or image leads to a (#324) Requires upload file error .

    Best way to avoid the 324 error.

提交回复
热议问题