gpt4 book ai didi

php - cURL cookie 值

转载 作者:可可西里 更新时间:2023-11-01 13:13:44 25 4
gpt4 key购买 nike

<分区>

我正在尝试从此站点下载音乐循环文件:looperman.com。我已经注册为用户,正在尝试使用 cURL 下载循环。当您登录到 looperman.com 时,会设置一些 cookie,但通过排除过程,我注意到服务器将您视为已登录所需的唯一一个名为“loopermanlooperman”。

我已获取该 cookie 的值,并将其设置为变量。然后我像这样将它传递给网站:

$sessid = 'somehashedvaluehere';

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: loopermanlooperman=$sessid;"));
curl_setopt($ch, CURLOPT_URL, "http://www.looperman.com/loops/detail/$pageID");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
echo $response;

当我回显响应时,我看到 cookie 尚未设置,并且该站点仍将我视为未登录。我做错了什么? Looperman 是使用 CodeIgniter 构建的。我想知道他们是否有一些保护措施来防止像这样设置 cookie?

///更新///

我尝试了 COOKIE_JAR 和 CURLOPT_COOKIE。 cookie 仍未设置。我从另一个 Stack Overflow 帖子中找到了这个脚本,它似乎让我了解了大部分内容,但仍然设置了 cookie。在这里:

$loginUrl = 'http://www.looperman.com/account/login/';
$loginFields = array('user_email' => 'login@site.com', 'user_password' => 'password');

getUrl($loginUrl, 'post', $loginFields);
//now you're logged in and a session cookie was generated

$remote_page_content = getUrl('http://www.looperman.com/loops/detail/200');
echo $remote_page_content;

function getUrl($url, $method='', $vars='') {
$ch = curl_init();
if ($method == 'post') {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'D:\wamp2\www\sandbox\cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'D:\wamp2\www\sandbox\cookie.txt');
$buffer = curl_exec($ch);
curl_close($ch);
return $buffer;
}

返回时,D:\wamp2\www\sandbox\cookie.txt 的内容是:

Netscape HTTP Cookie Filehttp://curl.haxx.se/rfc/cookie_spec.htmlThis file was generated by libcurl! Edit at your own risk..looperman.com  TRUE    /   FALSE   1329245288  loopermancspr   147f3f08a0b50f7aa527789e360abbc8.looperman.com  TRUE    /   FALSE   1328467688  loopermanlooperman  rX1UOdqyPEKkZ7HT0x8dSLk7g9yf5sSmg%2B7zj66hLM9LSmS1z4nqFO2zkEkqsUqKEwNMvEiExqSKoU2%2BfVsxlf3C9VyucMWt41TJVDtElUUIQrZxv0BmwZYP6JCJrY7wcT1%2FO7kKxRu8YI97YD%2BWdxX3jnWu2Zme9jg%2FMggp3%2Be%2BY%2FFiAorh36FR1zTbSY66VJVj7268WgMy6KNdJ1DxieypwaMb2HYGpBMsQRxcI6RawnOIEdjbaPKYuf8hVy40

但 looperman 仍然看不到我已登录 :(

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com