* login.php
'13001919???',
// "username" => 'nosuchuser',
"userpwd" => 'putongj3',
'luckdrawcode' => '',
'specialcode' =>'undefined'
];
$postdata = build_query($a);
array_push($headers, sprintf("Content-Length: %d", strlen($postdata)));
curl_setopt_array($ch, [
// CURLOPT_URL => 'http://172.16.0.224:8060/v1/login',
CURLOPT_URL => 'http://192.168.4.157:8060/v1/login',
CURLOPT_HEADER => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_POST => 1,
CURLOPT_BINARYTRANSFER => 1,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $postdata,
CURLOPT_CONNECTTIMEOUT => 3,
]);
$data = curl_exec($ch);
if (curl_errno($ch)) {
$msg = curl_error($ch);
printf("%s\n", $msg);
} else {
printf("%s\n", $data);
// write token o.data.token
$body = extract_http_body($data, "\r\n\r\n");
// printf("body=[%s]\n", $body);
$json = json_decode($body, false);
if ($json) {
file_put_contents("token.txt", $json->data->token);
}
}
curl_close($ch);
* run:
$ php login.php
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Cache-Control: no-cache, no-store, max-age=0, must-revalidate, value
Content-Type: application/json; charset=utf-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Last-Modified: Tue, 05 Mar 2019 08:03:51 GMT
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-Request-Id: 1af4693d-4b92-400b-8e85-f2b550529e61
X-Xss-Protection: 1; mode=block
Date: Tue, 05 Mar 2019 08:03:51 GMT
Content-Length: 221
{"code":0,"message":"OK","data":{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NTE3NzMwMzEsImlkIjoyOTY1MTYwNywibmJmIjoxNTUxNzczMDMxLCJ1c2VybmFtZSI6InB1dG9uZ2ozIn0.z1pzIFQ1FUF-8W2ZX9aDWbMjL9BOv5CHy1vKLvKKBeQ"}}
$ cat token.txt
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NTE3NzMwMzEsImlkIjoyOTY1MTYwNywibmJmIjoxNTUxNzczMDMxLCJ1c2VybmFtZSI6InB1dG9uZ2ozIn0.z1pzIFQ1FUF-8W2ZX9aDWbMjL9BOv5CHy1vKLvKKBeQ
2. 提取httpheader
* indexOf.php
301 Moved Permanently
301 Moved Permanently
nginx