Skip to content

Commit

Permalink
添加cookie格式化示例
Browse files Browse the repository at this point in the history
  • Loading branch information
Zjmainstay committed Dec 14, 2023
1 parent 38f516e commit 9ce1487
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions demo/49_format_cookie.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* cookie格式化与持久化示例
*/

require_once __DIR__.'/../vendor/autoload.php';

$autologin = new PHPCurl\CurlAutoLogin('', true);
$curl = <<<CURL
curl 'http://demo.zjmainstay.cn/js/simpleAjax/loginResult.php' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' \
-H 'Accept-Language: zh-CN,zh;q=0.9,en;q=0.8' \
-H 'Cache-Control: no-cache' \
-H 'Cookie: userIdentify=C96BEE3F333F8A676424211E19F15E06; Hm_lvt_2778aed5b668aa63a50ae9c5acd178f8=1699413729,1701801627; Hm_lpvt_2778aed5b668aa63a50ae9c5acd178f8=1701943275; Hm_lvt_1526d5aecf5561ef9401f7c7b7842a97=1702518307; Hm_lpvt_1526d5aecf5561ef9401f7c7b7842a97=1702518307; PHPSESSID=erpvlhe02137vdtvmff9ltgfu4' \
-H 'Pragma: no-cache' \
-H 'Proxy-Connection: keep-alive' \
-H 'Upgrade-Insecure-Requests: 1' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' \
--compressed \
--insecure
CURL;
$parseResult = $autologin->parseCurl($curl);
$cookieForFile = $autologin->formatHeaderCookieToFileContent($parseResult['cookie'], '.zjmainstay.cn');
$autologin->appendCookieContent($cookieForFile, true);
$content = $autologin->execCurl($curl);
var_dump($content, $autologin->getLastCookieContent());

0 comments on commit 9ce1487

Please sign in to comment.