Kendi localhostumdan post atmaya çalışıyorum fakat daha önce curl ile hiç uğraşmadığım için cookilerde sorun yaşadım. Post atmadan önce özel mesaj atarak test etmek istedim. Sorun şu; Siteye login oluyor, ileti gönderme sayfasına gidiyor, iletiyi yazıyor, mesajı gönder butonuna basıyor fakat "Oturumunuz sonlandı lütfen giriş yapın" hatasını veriyor. Yani sorun cookilerde. Kodlar şu şekil;
giris.php
<?php
// giris.php
$url = "http://www.xxx.com/forum/login2/";
$postfields = "user=xxx&passwrd=xxx&cookieneverexp=on";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_COOKIEJAR, "C:\wamp\www\cookie.txt");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
?>
msj.php
// msj.php
<?php
$url = "http://www.xxx.com/forum/pm/?sa=send2";
$post = "to=reptile&subject=Test&message=deneme&Submit=Mesaj%20Gönder";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, "C:\wamp\www\cookie.txt");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$out = curl_exec($ch);
curl_close($ch);
?>
yardımcı olabilecek arkadaşlara teşekkürler.