News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Logout with curl (php)

Started by Yojin_Spajin, March 29, 2014, 06:59:57 PM

Previous topic - Next topic

Yojin_Spajin

Hi,

I'm trying to build a php script for SM forum that is supposed to automate some MP check...

Cookie management is doing with php's curl library. Requests are OK, and I can collect and parse all that I want.

But then, I need to disconnect the account (in order to not overload the online members list).

There is the problematic issue. The logout action takes one argument "sesc".

Usually, it looks like : ?action=logout;sesc=638db9ce06e296d410a16dadae43f856

I can found the value of this argument parsing the source code of the curl generated page (in the link itself).

Like that, here he is : <a href="http://website.net/index.php?action=logout;sesc=638db9ce06e296d410a16dadae43f856">Logout</a>

Then, I try a new request with this argument... and that's make me an, meh, error :

QuoteSession verification failed. Please try logging out and back in again, and then try again.

So, I think there is an other thing that I've miss. Other bad point : the value of the sesc argument in the link change each time I make a new request.

Annex : My way make request with curl, where $url is the url (with action and arguments), and $path_cookie the path... to my cookie.

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_COOKIESESSION, true);
//curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($curl, CURLOPT_COOKIEFILE, realpath($path_cookie));
echo curl_exec($curl);


Great thank for helping me ! :)

Advertisement: