I have fully functional Cordova App, written using Framework7. Works perfect. Fetches posts, connects using categories, tags etc. Allows sharing. It's on playstore : Check Here..
My problem is, for 2 things : 1. i should be able to post comment from app directly, which I am not able to using JSON POST. It says "user should be logged in..". Actually my site is setup to accept comment from anyone without login. One has to just enter email and name. Then why is this not happening from cordova app?? See my code below. You may think that it has some scripting errors, but no, it calls the json perfectly and shows me error message..
url = "http://punashcha.com/wp-json/wp/v2/";
$$.post(url + 'comments', {
NONCE_KEY: '&.~OJCQN_s7*pEW(EG)-26](Eh`Fj}YP.]ZPYC2SPruX` g!/]8c>6>I|`_B[$6i',
content: $$(page.container).find('#comment-content').text(),
post: $$(page.container).find('#link').attr('postid')
},
function (data) {
me.alert("आपला अभिप्राय मिळाला. धन्यवाद!");
},
function (err, sts) {
me.alert("आपला अभिप्राय रजिस्टर झाला नाही. " + sts + err.responseText);
});
Am I suppose to send some header or something?
- I am using a membership plugin, that protects some of my paid posts. So from mobile app, i divert users to "website login" and get then logged in on mobile app browser. It maintains the state. Once this is done, it allows me to fetch complete protected posts. This means that my getJSON function sends proper authentication headers for mobile logged in user to fetch full data from wordpress.. The function call is -
$$.getJSON(url + "posts/?per_page=10&categories=23,24" + "&_envelope&_embed", function (json) {...})
If so, then why cant i make comment in same session?? is it that $$.post & $$.getJSON use different headers?
**i am not using any JSON plugin, and prefer not to.