First things first, I have a plug-in in my WordPress website called “WTI Like Post” which is a thumbs up plugin for voting posts…
Here’s a preview from its GitHub repository:
If you click on these thumbs, an ajax link will fire up and vote the post, then it redirects back to the post page again. That ajax link is something like this:
Now, I want to use these links manually! Meaning that I want to vote a post by copy and pasting that link in a new tab (And not by clicking on buttons). The problem is that when I paste the link myself, my browser returns an error:
“The page isn’t redirecting properly”.
I’m making an Android app for my website, and the only way I can think to vote a post, is that link.
How can I use it manually? And more importantly, how can I use it with Android’s HttpURLConnection?
Looking at the JavaScript source it would seem the Ajax link should be
http://example.com/wp-content/plugins/wti-like-post/wti_like.php
, with a POST body ofaction=wti_like_post_process_vote&task=like&post_id=108&nonce=0d8d1f993f
. Thus, on Android, using the example code here, this should work:Note that the nonce is not necessary on Android as
setUseCaches(false)
will ensure that the link is followed afresh every time.