{"id":267,"date":"2022-02-25T11:57:51","date_gmt":"2022-02-25T03:57:51","guid":{"rendered":"http:\/\/www.cgh0610.cn\/?p=267"},"modified":"2022-02-25T11:57:51","modified_gmt":"2022-02-25T03:57:51","slug":"%e4%bd%bf%e7%94%a8%e5%8f%8d%e5%b0%84%e5%87%bd%e6%95%b0%e5%a4%84%e7%90%86httpresponse-object","status":"publish","type":"post","link":"https:\/\/www.cgh0610.cn\/?p=267","title":{"rendered":"\u4f7f\u7528\u53cd\u5c04\u51fd\u6570\u5904\u7406httpresponse object"},"content":{"rendered":"<p>\u6700\u8fd1\u540c\u4e8b\u5728\u5bf9\u63a5\u63a5\u53e3\u7684\u65f6\u5019\u5f97\u5230\u4e86\u4e00\u4e2aHttpresponse Object\u5bf9\u8c61,\u8fd9\u73a9\u610f\u561b,\u6765,\u5927\u5bb6\u611f\u53d7\u4e0b<\/p>\n<pre><code class=\"json\">object(HttpResponse)#11 (7) {\n  [\"content\":\"HttpResponse\":private] => string(1047) \"HTTP\/1.1 200 OK\nServer: Tengine\nDate: Fri, 22 Jun 2018 09:52:33 GMT\nContent-Type: application\/json; charset=UTF-8\nContent-Length: 52\nConnection: keep-alive\nAccess-Control-Allow-Origin: *\nAccess-Control-Allow-Methods: GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH\nAccess-Control-Allow-Headers: X-Requested-With,X-Sequence,X-Ca-Key,X-Ca-Secret,X-Ca-Version,X-Ca-Timestamp,X-Ca-Nonce,X-Ca-API-Key,X-Ca-Stage,X-Ca-Client-DeviceId,X-Ca-Client-AppId,X-Ca-Signature,X-Ca-Signature-Headers,X-Ca-Signature-Method,X-Forwarded-For,X-Ca-Date,X-Ca-Request-Mode,Authorization,Content-Type,Accept,Accept-Ranges,Cache-Control,Range,Content-MD5\nAccess-Control-Max-Age: 172800\nX-Ca-Request-Id: CC7C80AD-3CCB-4F54-B14D-3BDA143AC3BE\nVary: Accept-Encoding\nufe-result: A2\nPragma: no-cache\nCache-Control: no-store\nVia: 71aae546d43b[web,200]\nSet-Cookie: SERVERID=c0cb0a9f805e8a70fc370b48877e9e8e|1529661153|1529661153;Path=\/\nX-Ca-Error-Message: OK\nX-Ca-Debug-Info: {\"TotalLatency\":81,\"ServiceLatency\":55}\n\n{\"code\":601,\"message\":\"\u6570\u636e\u4e0d\u5b58\u5728\",\"data\":null}\"\n  [\"body\":\"HttpResponse\":private] => string(52) \"{\"code\":601,\"message\":\"\u6570\u636e\u4e0d\u5b58\u5728\",\"data\":null}\"\n  [\"header\":\"HttpResponse\":private] => string(995) \"HTTP\/1.1 200 OK\nServer: Tengine\nDate: Fri, 22 Jun 2018 09:52:33 GMT\nContent-Type: application\/json; charset=UTF-8\nContent-Length: 52\nConnection: keep-alive\nAccess-Control-Allow-Origin: *\nAccess-Control-Allow-Methods: GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH\nAccess-Control-Allow-Headers: X-Requested-With,X-Sequence,X-Ca-Key,X-Ca-Secret,X-Ca-Version,X-Ca-Timestamp,X-Ca-Nonce,X-Ca-API-Key,X-Ca-Stage,X-Ca-Client-DeviceId,X-Ca-Client-AppId,X-Ca-Signature,X-Ca-Signature-Headers,X-Ca-Signature-Method,X-Forwarded-For,X-Ca-Date,X-Ca-Request-Mode,Authorization,Content-Type,Accept,Accept-Ranges,Cache-Control,Range,Content-MD5\nAccess-Control-Max-Age: 172800\nX-Ca-Request-Id: CC7C80AD-3CCB-4F54-B14D-3BDA143AC3BE\nVary: Accept-Encoding\nufe-result: A2\nPragma: no-cache\nCache-Control: no-store\nVia: 71aae546d43b[web,200]\nSet-Cookie: SERVERID=c0cb0a9f805e8a70fc370b48877e9e8e|1529661153|1529661153;Path=\/\nX-Ca-Error-Message: OK\nX-Ca-Debug-Info: {\"TotalLatency\":81,\"ServiceLatency\":55}\n\n\"\n  [\"requestId\":\"HttpResponse\":private] => string(36) \"CC7C80AD-3CCB-4F54-B14D-3BDA143AC3BE\"\n  [\"errorMessage\":\"HttpResponse\":private] => string(2) \"OK\"\n  [\"contentType\":\"HttpResponse\":private] => string(31) \"application\/json; charset=UTF-8\"\n  [\"httpStatusCode\":\"HttpResponse\":private] => int(200)\n}\n<\/code><\/pre>\n<p>\u8fd9\u4e2a\u6570\u636e\u5757,\u8ba9\u4eba\u6709\u70b9\u6478\u4e0d\u7740\u5934\u8111,\u5c1d\u8bd5\u4f7f\u7528\u4e86\u4ee5\u4e0b\u65b9\u6cd5\u90fd\u5931\u8d25\u544a\u7ec8<br \/>\n1.\u5f3a\u5236\u8f6c\u6570\u7ec4,(array) <span class=\"katex math inline\">data<br \/>\n2.json_decode(json_encode(<\/span>data),true)<br \/>\n3.\u76f4\u63a5\u7528$object->\u5c5e\u6027<\/p>\n<p>\u6700\u540e\u5728\u4e07\u80fd\u7684\u5ea6\u5a18\u5e2e\u52a9\u4e0b,\u4f7f\u7528\u4e86php\u7684\u53cd\u5c04\u51fd\u6570\u5904\u7406\u4e86\u6570\u636e<\/p>\n<pre><code class=\"php\">$ref = new ReflectionClass($response);\n        $props = $ref->getProperties();\n        $arr = [];\n\n\n        foreach ($props as $prop) {\n            $prop->setAccessible(true);\n            $arr[$prop->getName()] = $prop->getValue($response);\n            $prop->setAccessible(false);\n        }\n<\/code><\/pre>\n<p>\u6700\u540e\u5982\u613f\u5f97\u5230\u4e86\u4e00\u4e2a\u6570\u7ec4\u7c7b\u578b\u6570\u636e<\/p>\n<pre><code class=\"php\">array(7) {\n  [\"content\"] =&gt; string(1048) \"HTTP\/1.1 200 OK\nServer: Tengine\nDate: Mon, 25 Jun 2018 02:22:15 GMT\nContent-Type: application\/json; charset=UTF-8\nContent-Length: 52\nConnection: keep-alive\nAccess-Control-Allow-Origin: *\nAccess-Control-Allow-Methods: GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH\nAccess-Control-Allow-Headers: X-Requested-With,X-Sequence,X-Ca-Key,X-Ca-Secret,X-Ca-Version,X-Ca-Timestamp,X-Ca-Nonce,X-Ca-API-Key,X-Ca-Stage,X-Ca-Client-DeviceId,X-Ca-Client-AppId,X-Ca-Signature,X-Ca-Signature-Headers,X-Ca-Signature-Method,X-Forwarded-For,X-Ca-Date,X-Ca-Request-Mode,Authorization,Content-Type,Accept,Accept-Ranges,Cache-Control,Range,Content-MD5\nAccess-Control-Max-Age: 172800\nX-Ca-Request-Id: 271C3605-1937-4FF4-8D9B-D8E0F530875C\nCache-Control: no-store\nX-Ca-Error-Message: OK\nVary: Accept-Encoding\nufe-result: A2\nPragma: no-cache\nVia: 71aae546d43b[web,200]\nSet-Cookie: SERVERID=c0cb0a9f805e8a70fc370b48877e9e8e|1529893335|1529893335;Path=\/\nX-Ca-Debug-Info: {\"TotalLatency\":105,\"ServiceLatency\":56}\n\n{\"code\":601,\"message\":\"\u6570\u636e\u4e0d\u5b58\u5728\",\"data\":null}\"\n  [\"body\"] =&gt; string(52) \"{\"code\":601,\"message\":\"\u6570\u636e\u4e0d\u5b58\u5728\",\"data\":null}\"\n  [\"header\"] =&gt; string(996) \"HTTP\/1.1 200 OK\nServer: Tengine\nDate: Mon, 25 Jun 2018 02:22:15 GMT\nContent-Type: application\/json; charset=UTF-8\nContent-Length: 52\nConnection: keep-alive\nAccess-Control-Allow-Origin: *\nAccess-Control-Allow-Methods: GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH\nAccess-Control-Allow-Headers: X-Requested-With,X-Sequence,X-Ca-Key,X-Ca-Secret,X-Ca-Version,X-Ca-Timestamp,X-Ca-Nonce,X-Ca-API-Key,X-Ca-Stage,X-Ca-Client-DeviceId,X-Ca-Client-AppId,X-Ca-Signature,X-Ca-Signature-Headers,X-Ca-Signature-Method,X-Forwarded-For,X-Ca-Date,X-Ca-Request-Mode,Authorization,Content-Type,Accept,Accept-Ranges,Cache-Control,Range,Content-MD5\nAccess-Control-Max-Age: 172800\nX-Ca-Request-Id: 271C3605-1937-4FF4-8D9B-D8E0F530875C\nCache-Control: no-store\nX-Ca-Error-Message: OK\nVary: Accept-Encoding\nufe-result: A2\nPragma: no-cache\nVia: 71aae546d43b[web,200]\nSet-Cookie: SERVERID=c0cb0a9f805e8a70fc370b48877e9e8e|1529893335|1529893335;Path=\/\nX-Ca-Debug-Info: {\"TotalLatency\":105,\"ServiceLatency\":56}\n\n\"\n  [\"requestId\"] =&gt; string(36) \"271C3605-1937-4FF4-8D9B-D8E0F530875C\"\n  [\"errorMessage\"] =&gt; string(2) \"OK\"\n  [\"contentType\"] =&gt; string(31) \"application\/json; charset=UTF-8\"\n  [\"httpStatusCode\"] =&gt; int(200)\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u540c\u4e8b\u5728\u5bf9\u63a5\u63a5\u53e3\u7684\u65f6\u5019\u5f97\u5230\u4e86\u4e00\u4e2aHttpresponse Object\u5bf9\u8c61,\u8fd9\u73a9\u610f\u561b,\u6765,\u5927\u5bb6\u611f\u53d7\u4e0b obj &hellip; <a href=\"https:\/\/www.cgh0610.cn\/?p=267\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u4f7f\u7528\u53cd\u5c04\u51fd\u6570\u5904\u7406httpresponse object<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":[],"categories":[38,1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=\/wp\/v2\/posts\/267"}],"collection":[{"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=267"}],"version-history":[{"count":4,"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=\/wp\/v2\/posts\/267\/revisions"}],"predecessor-version":[{"id":275,"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=\/wp\/v2\/posts\/267\/revisions\/275"}],"wp:attachment":[{"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cgh0610.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}