{"id":104455,"date":"2021-09-21T08:18:59","date_gmt":"2021-09-21T00:18:59","guid":{"rendered":"https:\/\/www.keaglegz.com\/104455.html"},"modified":"2026-07-01T21:48:09","modified_gmt":"2026-07-01T13:48:09","slug":"php%e7%ae%80%e5%8d%95%e7%9a%84curl%e7%9a%84get%e8%af%b7%e6%b1%82%e5%92%8ccurl%e7%9a%84post%e8%af%b7%e6%b1%82%e5%92%8cfile_get_contents%e7%9a%84get%e8%af%b7%e6%b1%82%e8%8e%b7%e5%8f%96%e6%8e%a5%e5%8f%a3","status":"publish","type":"post","link":"https:\/\/www.dongwubaike.cn\/fanhao\/104455.html","title":{"rendered":"PHP\u7b80\u5355\u7684Curl\u7684Get\u8bf7\u6c42\u548cCurl\u7684Post\u8bf7\u6c42\u548cfile_get_contents\u7684Get\u8bf7\u6c42\u83b7\u53d6\u63a5\u53e3JSON\u6570\u636e"},"content":{"rendered":"\n<p>PHP\u643a\u5e26<a href=\"https:\/\/www.dongwubaike.cn\/fanhao\/tag\/ookie\" title=\"View all posts in Cookie\" target=\"_blank\">Cookie<\/a>\u7528Curl\u8fdb\u884cPost\u6216Get\u8bf7\u6c42\u83b7\u53d6\u6570\u636e<br \/> \u7b80\u5355\u7684curl\u8bf7\u6c42(Get\u8bf7\u6c42)<\/p>\n<pre>  &lt;?php  function hansCurl($url)  {  $url=&quot;https:\/\/www.vlwx.com&quot;;  $ip = rand(0, 255) . &#x27;.&#x27; . rand(0, 255) . &#x27;.&#x27; . rand(0, 255) . &#x27;.&#x27; . rand(0, 255);  $header[] = &quot;accept: application\/json&quot;;  $header[] = &quot;accept-encoding: gzip, deflate&quot;;  $header[] = &quot;accept-language: en-US,en;q=0.8&quot;;  $header[] = &quot;content-type: application\/json&quot;;  $header[] = &quot;CLIENT-IP:&quot; . $ip;  $header[] = &quot;X-FORWARDED-FOR:&quot; . $ip;  $cookie = &quot;cookie&quot;;  $ch = curl_init();  curl_setopt($ch, CURLOPT_URL, $url); \/\/\u8bbe\u7f6e\u4f20\u8f93\u7684 url  curl_setopt($ch, CURLOPT_HTTPHEADER, $header); \/\/\u53d1\u9001 http \u62a5\u5934  curl_setopt($ch, CURLOPT_COOKIE, $cookie); \/\/\u8bbe\u7f6eCookie  curl_setopt($ch, CURLOPT_REFERER, &quot;https:\/\/www.vvhan.com&quot;); \/\/\u8bbe\u7f6eReferer  curl_setopt($ch, CURLOPT_USERAGENT, &quot;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/79.0.3945.79 Safari\/537.36&quot;); \/\/\u8bbe\u7f6eUA  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  curl_setopt($ch, CURLOPT_ENCODING, &#x27;gzip,deflate&#x27;); \/\/ \u89e3\u7801\u538b\u7f29\u6587\u4ef6  \/\/curl_setopt($ch, CURLOPT_COOKIEJAR, &quot;.\/cookie\/cookie.txt&quot;);\/\/\u4fdd\u5b58cookie\u6587\u4ef6  \/\/curl_setopt($ch, CURLOPT_COOKIEFILE, &quot;.\/cookie\/cookie.txt&quot;); \/\/\u8c03\u7528cookie\u6587\u4ef6  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); \/\/ \u5bf9\u8ba4\u8bc1\u8bc1\u4e66\u6765\u6e90\u7684\u68c0\u67e5  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); \/\/ \u4ece\u8bc1\u4e66\u4e2d\u68c0\u67e5SSL\u52a0\u5bc6\u7b97\u6cd5\u662f\u5426\u5b58\u5728  curl_setopt($ch, CURLOPT_TIMEOUT, 5); \/\/ \u8bbe\u7f6e\u8d85\u65f6\u9650\u5236\u9632\u6b62\u6b7b\u5faa\u73af  $output = curl_exec($ch);  curl_close($ch);  return $output;  }  ?&gt;  <\/pre>\n<p>\u7b80\u5355\u7684curl\u8bf7\u6c42(Post\u8bf7\u6c42)<\/p>\n<pre>  &lt;?php  function hansCurl($url)  {  $url=&quot;https:\/\/www.vlwx.com&quot;;  $ip = rand(0, 255) . &#x27;.&#x27; . rand(0, 255) . &#x27;.&#x27; . rand(0, 255) . &#x27;.&#x27; . rand(0, 255);  $header[] = &quot;accept: application\/json&quot;;  $header[] = &quot;accept-encoding: gzip, deflate&quot;;  $header[] = &quot;accept-language: en-US,en;q=0.8&quot;;  $header[] = &quot;content-type: application\/json&quot;;  $header[] = &quot;CLIENT-IP:&quot; . $ip;  $header[] = &quot;X-FORWARDED-FOR:&quot; . $ip;  $cookie=&quot;cookie&quot;;  $post_data = array(      &quot;token&quot; =&gt; &quot;123456&quot;  );  $ch = curl_init();  curl_setopt($ch, CURLOPT_URL, $url);\/\/\u8bbe\u7f6e\u4f20\u8f93\u7684 url  curl_setopt($ch, CURLOPT_HTTPHEADER, $header); \/\/\u53d1\u9001 http \u62a5\u5934  curl_setopt($ch, CURLOPT_COOKIE, $cookie);\/\/\u8bbe\u7f6eCookie  curl_setopt($ch, CURLOPT_REFERER, &quot;https:\/\/www.vvhan.com&quot;);\/\/\u8bbe\u7f6eReferer  curl_setopt($ch, CURLOPT_USERAGENT, &quot;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/79.0.3945.79 Safari\/537.36&quot;);\/\/\u8bbe\u7f6eUA  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  curl_setopt($ch, CURLOPT_ENCODING, &#x27;gzip,deflate&#x27;); \/\/ \u89e3\u7801\u538b\u7f29\u6587\u4ef6  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);\/\/ \u5bf9\u8ba4\u8bc1\u8bc1\u4e66\u6765\u6e90\u7684\u68c0\u67e5  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);\/\/ \u4ece\u8bc1\u4e66\u4e2d\u68c0\u67e5SSL\u52a0\u5bc6\u7b97\u6cd5\u662f\u5426\u5b58\u5728  curl_setopt($ch, CURLOPT_TIMEOUT, 5); \/\/ \u8bbe\u7f6e\u8d85\u65f6\u9650\u5236\u9632\u6b62\u6b7b\u5faa\u73af  curl_setopt($ch, CURLOPT_POST, 1); \/\/\u8bbe\u7f6ePOST\u53d1\u9001\u6570\u636e  curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);\/\/\u53d1\u9001POST\u6570\u636e\u5185\u5bb9  \/\/curl_setopt($ch, CURLOPT_COOKIEJAR, &quot;.\/cookie\/cookie.txt&quot;);\/\/\u4fdd\u5b58cookie\u6587\u4ef6  \/\/curl_setopt($ch, CURLOPT_COOKIEFILE, &quot;.\/cookie\/cookie.txt&quot;); \/\/\u8c03\u7528cookie\u6587\u4ef6  $output = curl_exec($ch);  curl_close($ch);  return $output;  }  ?&gt;  <\/pre>\n<p>PHP\u7684curl\u4e0a\u4f20\u6587\u4ef6(Post\u8bf7\u6c42)<\/p>\n<p><a href=\"https:\/\/www.dongwubaike.cn\/fanhao\/wp-content\/uploads\/2024\/06\/haode2332332.jpg\" data-fancybox=\"images\"><img decoding=\"async\" src=\"https:\/\/www.dongwubaike.cn\/fanhao\/wp-content\/uploads\/2024\/06\/haode2332332.jpg\" alt=\"\"><\/a><\/p>\n<pre>  &lt;?php  function hansCurl($url)  {  $url = &quot;https:\/\/www.vlwx.com&quot;;  $names=&quot;1.png&quot;;  $ip = rand(0, 255) . &#x27;.&#x27; . rand(0, 255) . &#x27;.&#x27; . rand(0, 255) . &#x27;.&#x27; . rand(0, 255);  $header[] = &quot;accept: application\/json&quot;;  $header[] = &quot;accept-encoding: gzip, deflate&quot;;  $header[] = &quot;accept-language: en-US,en;q=0.8&quot;;  $header[] = &quot;content-type: application\/json&quot;;  $header[] = &quot;CLIENT-IP:&quot; . $ip;  $header[] = &quot;X-FORWARDED-FOR:&quot; . $ip;  $cookie = &quot;cookie&quot;;  $post_data = [      &#x27;name&#x27; =&gt; $names,      &#x27;attrFile&#x27; =&gt; new CURLFile(realpath(&#x27;hanCURLFile\/&#x27; . $names)),  ];  $ch = curl_init(); \/\/ \u542f\u52a8\u4e00\u4e2aCURL\u4f1a\u8bdd  curl_setopt($ch, CURLOPT_URL, $url); \/\/ \u8981\u8bbf\u95ee\u7684\u5730\u5740  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); \/\/ \u5bf9\u8ba4\u8bc1\u8bc1\u4e66\u6765\u6e90\u7684\u68c0\u67e5  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); \/\/ \u4ece\u8bc1\u4e66\u4e2d\u68c0\u67e5SSL\u52a0\u5bc6\u7b97\u6cd5\u662f\u5426\u5b58\u5728  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); \/\/ \u83b7\u53d6\u7684\u4fe1\u606f\u4ee5\u6587\u4ef6\u6d41\u7684\u5f62\u5f0f\u8fd4\u56de  curl_setopt($ch, CURLOPT_HTTPHEADER, $header);  curl_setopt($ch, CURLOPT_USERAGENT, &#x27;Mozilla\/5.0 (Windows NT 10.0; WOW64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/79.0.3945.130 Safari\/537.36&#x27;); \/\/ \u6a21\u62df\u7528\u6237\u4f7f\u7528\u7684\u6d4f\u89c8\u5668  curl_setopt($ch, CURLOPT_POST, 1); \/\/ \u53d1\u9001\u4e00\u4e2a\u5e38\u89c4\u7684Post\u8bf7\u6c42  curl_setopt($ch, CURLOPT_REFERER, &#x27;https:\/\/www.vvhan.com&#x27;); \/\/ \u81ea\u52a8\u8bbe\u7f6eReferer  curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); \/\/ Post\u63d0\u4ea4\u7684\u6570\u636e\u5305  curl_setopt($ch, CURLOPT_ENCODING, &#x27;gzip&#x27;);  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); \/\/ \u4f7f\u7528\u81ea\u52a8\u8df3\u8f6c  curl_setopt($ch, CURLOPT_TIMEOUT, 5); \/\/ \u8bbe\u7f6e\u8d85\u65f6\u9650\u5236\u9632\u6b62\u6b7b\u5faa\u73af  curl_setopt($ch, CURLOPT_HEADER, 0); \/\/ \u663e\u793a\u8fd4\u56de\u7684Header\u533a\u57df\u5185\u5bb9  \/\/curl_setopt($ch, CURLOPT_COOKIEJAR, &quot;.\/cookie\/cookie.txt&quot;);\/\/\u4fdd\u5b58cookie\u6587\u4ef6  \/\/curl_setopt($ch, CURLOPT_COOKIEFILE, &quot;.\/cookie\/cookie.txt&quot;); \/\/\u8c03\u7528cookie\u6587\u4ef6  $output = curl_exec($ch); \/\/ \u6267\u884c\u64cd\u4f5c  curl_close($ch); \/\/ \u5173\u95edCURL\u4f1a\u8bdd  return ($output);  }  ?&gt;  <\/pre>\n<p>\u7b80\u5355\u7684file_get_contents\u8bf7\u6c42(Get\u8bf7\u6c42)<\/p>\n<pre>  &lt;?php  $url = &#x27;https:\/\/www.vlwx.com\/&#x27;;  $data = file_get_contents($url);  exit($data);  ?&gt;  <\/pre>\n","protected":false},"excerpt":{"rendered":"<p>PHP\u643a\u5e26Cookie\u7528Curl\u8fdb\u884cPost\u6216Get\u8bf7\u6c42\u83b7\u53d6\u6570\u636e<br \/>\n \u7b80\u5355\u7684curl\u8bf7\u6c42(Get\u8bf7\u6c42)\u7b80\u5355\u7684curl\u8bf7\u6c42(Post\u8bf7\u6c42)<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[10379],"class_list":["post-104455","post","type-post","status-publish","format-standard","hentry","tag-ookie"],"_links":{"self":[{"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/posts\/104455","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/comments?post=104455"}],"version-history":[{"count":1,"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/posts\/104455\/revisions"}],"predecessor-version":[{"id":286195,"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/posts\/104455\/revisions\/286195"}],"wp:attachment":[{"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/media?parent=104455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/categories?post=104455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/tags?post=104455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}