{"id":49364,"date":"2024-12-02T11:15:34","date_gmt":"2024-12-02T03:15:34","guid":{"rendered":"https:\/\/fwq.ai\/blog\/49364\/"},"modified":"2024-12-02T11:15:34","modified_gmt":"2024-12-02T03:15:34","slug":"php-curl-%e5%a6%82%e4%bd%95%e6%b7%bb%e5%8a%a0%e8%ba%ab%e4%bb%bd%e9%aa%8c%e8%af%81%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/49364\/","title":{"rendered":"PHP Curl \u5982\u4f55\u6dfb\u52a0\u8eab\u4efd\u9a8c\u8bc1\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>PHP Curl \u5982\u4f55\u6dfb\u52a0\u8eab\u4efd\u9a8c\u8bc1\uff1f<\/h1>\n<p>\u54c8\u55bd\uff01\u4eca\u5929\u5fc3\u8840\u6765\u6f6e\u7ed9\u5927\u5bb6\u5e26\u6765\u4e86<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aPHP Curl \u5982\u4f55\u6dfb\u52a0\u8eab\u4efd\u9a8c\u8bc1\uff1f\u300b<\/span>\uff0c\u60f3\u5fc5\u5927\u5bb6\u5e94\u8be5\u5bf9<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u90fd\u4e0d\u964c\u751f\u5427\uff0c\u90a3\u4e48\u9605\u8bfb\u672c\u6587\u5c31\u90fd\u4e0d\u4f1a\u5f88\u56f0\u96be\uff0c\u4ee5\u4e0b\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\uff0c\u82e5\u662f\u4f60\u6b63\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\uff0c\u5343\u4e07\u522b\u9519\u8fc7\u8fd9\u7bc7\u6587\u7ae0~\u5e0c\u671b\u80fd\u5e2e\u52a9\u5230\u4f60\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241130\/1732952365674ac12db878e.jpg\" class=\"aligncenter\" title=\"PHP Curl \u5982\u4f55\u6dfb\u52a0\u8eab\u4efd\u9a8c\u8bc1\uff1f\u63d2\u56fe\" alt=\"PHP Curl \u5982\u4f55\u6dfb\u52a0\u8eab\u4efd\u9a8c\u8bc1\uff1f\u63d2\u56fe\" \/><\/p>\n<p>\u5982\u4f55\u5728 php \u7684 curl \u4e2d\u6dfb\u52a0\u8eab\u4efd\u9a8c\u8bc1<\/p>\n<p>\u9047\u5230\u8fd9\u6837\u7684\u95ee\u9898\uff1a<\/p>\n<pre>get \/snapshot?ext=[jpg|png]&amp;compress=[0.1-1]&amp;orient=[0|1|2|3] http\/1.1\nhost: [\u670d\u52a1\u7aef ip]\nauth: [\u9a8c\u8bc1\u4e32]<\/pre>\n<p>\u9700\u8981\u5728 curl \u4e2d\u6dfb\u52a0\u6388\u6743\uff0c\u4f46\u4e0d\u77e5\u9053\u5982\u4f55\u4f7f\u7528\u54ea\u4e2a\u51fd\u6570\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<p>\u6839\u636e stackoverflow \u4e0a\u7684\u8ba8\u8bba\uff08\u53c2\u8003\uff1ahttp:\/\/stackoverflow.com\/questions\/20064271\/how-to-use-basic-authorization-in-php-curl\uff09\uff0c\u53ef\u4ee5\u4f7f\u7528 curl_setopt \u51fd\u6570\uff1a<\/p>\n<pre>curl_setopt($ch, CURLOPT_USERPWD, \"&lt;span style=\"color: #800080\"&gt;$username&lt;\/span&gt;:&lt;span style=\"color: #800080\"&gt;$password&lt;\/span&gt;\");<\/pre>\n<p>\u4eca\u5929\u5173\u4e8e\u300aPHP Curl \u5982\u4f55\u6dfb\u52a0\u8eab\u4efd\u9a8c\u8bc1\uff1f\u300b\u7684\u5185\u5bb9\u5c31\u4ecb\u7ecd\u5230\u8fd9\u91cc\u4e86\uff0c\u662f\u4e0d\u662f\u5b66\u8d77\u6765\u4e00\u76ee\u4e86\u7136\uff01\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u5185\u5bb9\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP Curl \u5982\u4f55\u6dfb\u52a0\u8eab\u4efd\u9a8c\u8bc1\uff1f \u54c8\u55bd\uff01\u4eca\u5929\u5fc3\u8840\u6765\u6f6e\u7ed9\u5927\u5bb6\u5e26\u6765\u4e86\u300aPHP Curl \u5982\u4f55\u6dfb\u52a0\u8eab\u4efd\u9a8c\u8bc1\uff1f\u300b\uff0c\u60f3\u5fc5\u5927\u5bb6\u5e94\u8be5\u5bf9\u6587\u7ae0\u90fd\u4e0d\u964c\u751f\u5427\uff0c\u90a3\u4e48\u9605\u8bfb\u672c\u6587\u5c31\u90fd\u4e0d\u4f1a\u5f88\u56f0\u96be\uff0c\u4ee5\u4e0b\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230\uff0c\u82e5\u662f\u4f60\u6b63\u5728\u5b66\u4e60\u6587\u7ae0\uff0c\u5343\u4e07\u522b\u9519\u8fc7\u8fd9\u7bc7\u6587\u7ae0~\u5e0c\u671b\u80fd\u5e2e\u52a9\u5230\u4f60\uff01 \u5982\u4f55\u5728 php \u7684 curl \u4e2d\u6dfb\u52a0\u8eab\u4efd\u9a8c\u8bc1 \u9047\u5230\u8fd9\u6837\u7684\u95ee\u9898\uff1a get \/snapshot?ext=[jpg|png]&amp;compress=[0.1-1]&amp;orient=[0|1|2|3] http\/1.1 host: [\u670d\u52a1\u7aef ip] auth: [\u9a8c\u8bc1\u4e32] \u9700\u8981\u5728 curl \u4e2d\u6dfb\u52a0\u6388\u6743\uff0c\u4f46\u4e0d\u77e5\u9053\u5982\u4f55\u4f7f\u7528\u54ea\u4e2a\u51fd\u6570\u3002 \u89e3\u51b3\u65b9\u6cd5\uff1a \u6839\u636e stackoverflow \u4e0a\u7684\u8ba8\u8bba\uff08\u53c2\u8003\uff1ahttp:\/\/stackoverflow.com\/questions\/20064271\/how-to-use-basic-authorization-in-php-curl\uff09\uff0c\u53ef\u4ee5\u4f7f\u7528 curl_setopt \u51fd\u6570\uff1a curl_setopt($ch, CURLOPT_USERPWD, &#8220;&lt;span style=&#8221;color: #800080&#8243;&gt;$username&lt;\/span&gt;:&lt;span style=&#8221;color: #800080&#8243;&gt;$password&lt;\/span&gt;&#8221;); \u4eca\u5929\u5173\u4e8e\u300aPHP Curl \u5982\u4f55\u6dfb\u52a0\u8eab\u4efd\u9a8c\u8bc1\uff1f\u300b\u7684\u5185\u5bb9\u5c31\u4ecb\u7ecd\u5230\u8fd9\u91cc\u4e86\uff0c\u662f\u4e0d\u662f\u5b66\u8d77\u6765\u4e00\u76ee\u4e86\u7136\uff01\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u5185\u5bb9\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-49364","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49364","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=49364"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49364\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=49364"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=49364"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=49364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}