Я был вокруг этого сайта, ища решение по моему вопросу, некоторые ответы близки, но не так много, чтобы найти решение моей проблемы. У меня есть PHP curl для входа на определенный сайт и перенаправления на определенную ссылку. зарегистрировано в системе.Simple CURL redirect
***First to log:***
$ ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https >somesite');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 100);
curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $uagent);
curl_setopt($ch, CURLOPT_REFERER, 'some other site');
curl_setopt($ch, CURLOPT_TIMEOUT, 220);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).DS.'cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).DS.'cookies.txt');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,'userid='.$log.'&password='.$pass.);
$content = curl_exec($ch)
***then run this to get away from page with ads ***
$info = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
$fnd='ads'; ***// check to see if has ads***
$pos=strpos($info, $fnd);
if ($pos!==false)
{
$url1 = "https - link to redirect while logged id"; // ***I have this link for sure***
$ch1 = curl_init();
curl_setopt ($ch1, CURLOPT_URL, $url1);
curl_setopt ($ch1, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch1, CURLOPT_USERAGENT, $uagent);
curl_setopt($ch1, CURLOPT_HEADER, 1);
curl_setopt ($ch1, CURLOPT_COOKIESESSION, 0);
curl_setopt ($ch1, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch1, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch1, CURLOPT_CONNECTTIMEOUT ,100);
curl_setopt ($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch1, CURLOPT_COOKIEJAR, dirname(__FILE__).DS.'cookies.txt');
curl_setopt ($ch1, CURLOPT_COOKIEFILE, dirname(__FILE__).DS.'cookies.txt');
curl_setopt ($ch1, CURLOPT_POST, 0);
$content = curl_exec ($ch1);
но это не работает.
Кто бы сказал мне любезно?
спасибо.
Не могли бы вы подробнее рассказать о «нерабочем»? Например, вы получаете сообщение об ошибке? – Martijn