I am working on phonegap app and using drupal 7 as backend for all json request data. I am using the service module for it. At frontend I am using Angular js in phonegap.
I referred http:// drupal.stackexchange.com/questions/22277/creating-comments-and-nodes-with-services-3-x-and-json for posting comment.
I set permission for anonymous user to post comment to any node from drupal permission section. But its not posting any comment. Giving me error.
/appapi/comment.json 403: Access denied for user anonymous
Here is my code:
var dataObj = {"subject":$comment.text, "comment_body":{"und":[{"value":$comment.text}]}, "nid":$comment.nid} ;
var res = $http.post($scope.apiBaseUrl+'/appapi/comment.json', dataObj,{ withCredentials: false, headers: { 'Content-Type': 'application/json'} }); res.success(function(data, status, headers, config)
{ //$scope.message = data;
console.log(data);
});
Here is CROS module setting:
*|*|POST,GET,PUT,DELETE|Origin, X-Requested-With, Content-Type, Accept|false
I am sending comment post request from phonegap app. I am not using the AgularJS module.
var dataObj = {"subject":$comment.text, "comment_body":{"und":[{"value":$comment.text}]}, "nid":$comment.nid} ; var res = $http.post($scope.apiBaseUrl+'/appapi/comment.json', dataObj,{ withCredentials: false, headers: { 'Content-Type': 'application/json'} }); res.success(function(data, status, headers, config) { //$scope.message = data; console.log(data); $ionicLoading.hide(); });
I have already set permission for anonymous user to post comment via permissions.angular-drupal
module, then all you have to do is callcomment_save();
: github.com/easystreet3/angular-drupal