Posting image to facebook Graph API using angularjs

I'm trying to upload an image to facebook ... Unfortunately the facebook API always returns the following error:

{ error: Objectcode: 324, message: "(#324) Requires upload file", type: "OAuthException" }

      

The image data does not seem to be transmitted correctly. The facebook docs tell me that you are using multipart / form-data upload. (See here > Publishing)

I am using angular-easyfb as a wrapper for my faceebook sdk. What's the easiest way to get this to work? My current code:

var sharePhoto = function() {
    ezfb.api("/me/photos",
       "POST",
       {
           "source": content,
           "message": "This is a test Photo"
       },
       function (response) {
           console.log("shared", response);
           if (response && !response.error) {
              /* handle the result */
           }
       });
};

ezfb.getLoginStatus(function(response) {
    if(response.status === 'connected') {
        console.log("already conntected", response);
        sharePhoto();
    } else {
        ezfb.login(function(response) {
            // Do something with response.
            console.log("FB",response);
            sharePhoto();
        }, {scope: 'public_profile,email,user_photos,publish_actions'});
    }
});

      

Console log:

already conntected {status: "connected", authResponse: Object} 
shared {error: {code: 324, message: "(#324) Requires upload file", type: "OAuthException"}}

      

My questions:

  • What is the expected format for my variable content? How do I need to encode?
  • Do I need to manipulate the request for request headers? How?

Many thanks for your help!

Edit: Added console log

+3
javascript angularjs facebook-graph-api


source to share


No one has answered this question yet

Check out similar questions:

4523
Thinking in AngularJS if I have a jQuery background?
3178
AngularJS: Service vs provider vs factory
1690
How does data binding work in AngularJS?
1571
How does Facebook disable built-in developer tools?
1195
How do I access the $ scope variable in the browser console using AngularJS?
969
What are the nuances of the scope of prototype / prototypal inheritance in AngularJS?
912
'this' vs $ scope in AngularJS controllers
1
Share facebook video with custom post using jssdk version 2.0
1
OAuthException 1 when posting an image to facebook by calling / me / photos api
0
Facebook Graph API - (# 200) Permissions error on page submission



All Articles
Loading...
X
Show
Funny
Dev
Pics