Wizcorp / phonegap-facebook-plugin

The official plugin for Facebook in Apache Cordova/PhoneGap
Other
1.91k stars 2k forks source link

Need to post image captured by camera #1241

Open DhyanandraSingh opened 8 years ago

DhyanandraSingh commented 8 years ago

2016-03-04 I want to upload selfie on facebook profile using cordova apps so i used cordovaCamera for capturing a image then use showDialog to upload this captured image on facebook. but i got an api error code 100. i.e. picture is not properly formatted.

code:

function onDeviceReady() {
             options = {
                destinationType: Camera.DestinationType.FILE_URI,
                sourceType: Camera.PictureSourceType.CAMERA,
                allowEdit: true,
                encodingType: Camera.EncodingType.JPEG,
                correctOrientation:true,
                quality: 80,
                targetWidth: 300,
                targetHeight: 300,
                correctOrientation: true
        };
     }

  $scope.selfie = function() {
       $cordovaCamera.getPicture(options).then(function(imageURI) {
             alert("image location"+ imageURI);
             $scope.facebookImagePost(imageURI);
        }, function(err) {
                    alert(" camera error"+ err);
           });
  }

   $scope.facebookImagePost= function( imageURI ){
            var options = {
                    method: "feed",
                    picture: imageURI,
                    caption: " testing caption",
                    description: 'testing fb post'
                  };
                  alert(JSON.stringify(options.picture));
                  $cordovaFacebook.showDialog(options)
                    .then(function(success) {
                      alert( JSON.stringify(success));
                    }, function (error) {
                      // error
                      alert( JSON.stringify(error));
                    });
   }