Create POST (protocol) for Wordpress from reading debugging tool Chrome

I have a button on my page WordPress to check or uncheck the post of WordPress as favorite. It is my intention to make a POST call from php to do this. Later I call this php from a mobile app.

My App Mobile ==> (get_favorito.php) POST (idUser, idPost, Status) ==> Favorite ON / OFF

I currently use WP 4.4.2 and Plugin for WordPress FAVORITES (

I launch the POST used the tool for developers of Chrome.

image important debugging

And I can see that the call is made:


My question comes with the part of Header and Cookie. How did you get this information?

I'm trying this, but it does not work. This is the php I am writing.


$ruta = 'http://' . $_SERVER['HTTP_HOST'];
$json = file_get_contents($ruta . '/wp-admin/admin-ajax.php?action=simplefavorites_nonce');

$arr = json_decode($json, true);
$nonce = $arr['nonce'];

$opts = array(
    'header'=> 'POST /wp-admin/admin-ajax.php HTTP/1.1\r\n' .
        'Host:\r\n' .
        'Connection: keep-alive\r\n' .
        'Content-Length: 84\r\n' .
        'Accept: */*\r\n' .
        'Origin:\r\n' .
        'X-Requested-With: XMLHttpRequest\r\n' .
        'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36\r\n' .
        'Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n' .
        'Referer:\r\n' .
        'Accept-Encoding: gzip, deflate\r\n' .
        'Accept-Language: es-ES,es;q=0.8\r\n' .
        'Cookie: wordpress_dddd3333f97127bf3816f4455971ce5aa=peteradmin%7C1457085836%7CxWJrk7EQVEYRpZY9Jzev4fH6jx3cq97wx6LPaMd9C4v%7Cd232ca14edca535e653dd37607b754d78926410e317d34315cbcb5533cda08c8; PHPSESSID=8eda0049e17a67becb1c8fddd18c6c51;






$context = stream_context_create($opts);

$param = "action=simplefavorites_favorite&nonce='.$nonce.'&postid=273&siteid=1&status=active";
$json = file_get_contents($ruta . '/wp-admin/admin-ajax.php?'.$param.'', false, $context);
echo $json;


(I put spaces so that cookies are correctly displayed)

And now I get nonce with:


Hello I was redirected here from nubelo in order to answer.

The headers are set automatically by the browser and the cookies are set by different pages of wordpress like the wp-login.php page.

The simplefavorites cookie is a cookie that stores an anonymoys user favorite posts array, and it is returned in the response headers of the wp-admin/admin-ajax.php?action=simplefavorites_array page. For logged in users the favorites information is returned in json format in the response of that same page.

I made a php script to toggle the status it just sends the cookies to the respective endpoints and you would only need to store the cookies in your mobile app and send them with your request.

Need Your Help

Disable PropertySortOrder in SCSS-Lint in Atom

sass atom-editor lint scss-lint

I would like to disable PropertySortOrder( in SCSS-Lint in Atom, though the documentation doesn't really spec...