2016-08-17 6 views
4

촬영 한 사진을 Instagram에 공유하려고합니다. 설치 한 사람 : social share plugin from ngCordova websiteIonic을 사용하여 Instagram에 사진을 공유하는 방법

하지만 제대로 작동하지 않습니다. 그것을 실행할 때 오류가 없습니다. 성공 응답을 얻었지만 이미지가 Instagram의 벽에 게시되지 않았습니다.

로그 (xcode -> 실제 장치에서 테스트까지 실행 중)의 인쇄 화면입니다. enter image description here

내가 뭘 잘못하고 있는지 누가 알 수 있습니까? 내 HTML 코드의

app.controller('CameraCtrl', function($scope, $cordovaCamera, $cordovaSocialSharing, $rootScope, $state){ 

    $scope.takePicture = function(){ 
    var options = { 
     quality: 75, 
     destinationType: Camera.DestinationType.DATA_URI, 
     sourceType: Camera.PictureSourceType.CAMERA, 
     encodingType: Camera.EncodingType.JPEG, 
     saveToPhotoAlbum: true, 
     correctOrientation:true 
    }; 
    $cordovaCamera.getPicture(options) 
     .then(function(imageURI){ 
      var imagePlaceholder = document.getElementById('placeholderPicture'); 
      imagePlaceholder.src = imageURI; 
      $rootScope.imgShare = imageURI; 
      //$scope.imgURI = "data:image/jpeg;base64," + imageURI; 
      //$state.go('app.camera', {image: $scope.imgURI}); 
      //console.log('camera data: ' + angular.toJson(imageURI)); 
     }, function(error){ 
      console.log('error camera data: ' + angular.toJson(imageURI)); 
    }); 
    } 

$scope.shareViaInstagram = function(message, image){ 
    socialType = "instagram"; 
    message = "test"; 
    image = $rootScope.imgShare; 

    $cordovaSocialSharing.shareVia(socialType, message, image, null).then(function(result) { 
     console.log('image shared to Instagram ', result); 
     console.log('dddd', image); 
     console.log('######', $rootScope.imgShare); 
     //$state.go('app.finish'); 
}, function(err) { 
     console.log('error in sharing to Instagram ', err); 
}); 

    } 

}); 

부 :

<div class="wrapperCamera"> 
     <div class="cameraContent padding"> 
      <img id="placeholderPicture" ng-src="{{imgShare}}"> 
      <br> 
      <h2 class="customH2Camera">looking good!</h2> 
      <br><br> 
      <div class="socialIcons"> 
       <a href="" ng-click="shareViaInstagram(null, null, imgShare, null)"><img src="img/iconInstagram.svg" width="40"></a> 
       &nbsp;&nbsp;&nbsp; 
       <a href="" ng-click="shareViaFacebook(null, null, imgShare, null)"><img src="img/iconFacebook.svg" width="40"></a> 
      </div> 
     </div><!-- end cameraContent --> 
    </div><!-- end WrapperCamera -->  
+0

당신이 NG-코르도바 누락 될 수 있습니까? –

+0

아니요, 내 app.js 파일에 추가했습니다. – GY22

+0

질문에 오류가 발생했습니다. –

답변

1
module.controller('ThisCtrl', function($scope, $cordovaInstagram) { 
     // Get image from camera, base64 is good. See the 
     // $cordovaCamera docs for more info 
     $cordovaInstagram.share($scope.image.data, $scope.image.caption).then(function() { 
     // Worked 
     }, function(err) { 
     // Didn't work 
     }); 
    }) 
+0

그리고이 플러그인을 추가해야합니다. (cordova plugin add https://github.com/vstirbu/InstagramPlugin.git) – imtiyaz

+0

i 해당 플러그인을 이미 설치했습니다. – GY22

1

은 코르도바의 deviceready 이벤트 내에서 플러그인 전화를 감싸 여기

내 컨트롤러 코드의 일부입니다. 플러그 인을 호출하기 전에 장치가 완전히로드되었는지 확인합니다.

document.addEventListener("deviceready", function() { 
    // your plugin call here 
}); 

또한 $ionicPlatform.ready(function() {});

더 많은 정보를 원하시면이 읽기 사용할 수 있습니다 ngCordova common issues

관련 문제