我成功使用网络服务登录远程网站(我不拥有),但是当我刷新时我失去了连接。我注意到SID有一个cookie,当我删除它时,我失去了联系。所以我试图找到一种设置这些cookie的方法,但我已经失败了。有没有其他解决方案可以保持连接?
<?php
setcookie("testcookie", "value1hostonly", time()+3600, "/",
".freedownloadmobileringtones.com/", 0, true);
try
{
$payload = '{
"service":"X",
"method":"CUS",
"id":2,
"params": [
"username",
"pwd",
"GMT+05:00",2
], "server_data":{ "sid": -1}
}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.exemple.com.tn/services?nocache='.time());
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(' POST /services?nocache=1499940324678 HTTP/1.1',
'Host: www.exemple.com.tn',
'Connection: keep-alive',
'Content-Length:'. strlen( $payload ),
'Pragma: no-cache',
'Origin: http://www.exemple.com.tn',
'User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36',
'Content-Type: application/json',
'X-Qooxdoo-Response-Type: application/json',
'Cache-Control: no-cache',
'Accept: */*',
'Referer: http://www.exemple.com.tn/track/',
'Accept-Encoding: gzip, deflate',
'Accept-Language: en-GB,en;q=0.8,en-US;q=0.6,ar;q=0.4,fr;q=0.2',
'Cookie: TawkConnectionTime='.time())
);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
$result = curl_exec($ch);
header("Location:http://www.exemple.com.tn/track?nocache=".time());
$ch = curl_init();
}
catch (Exception $e)
{
echo $e->getMessage();
}
?>