Php-解码http响应

问题描述

我需要将请求的响应解码为数组

            $result = $this->sendHttpRequestFromHook($hook,$item);
            $customer = $result['response'];
            $customerDec = json_decode($customer,true);

$ result包含成功,响应和状态的数组,我将响应分隔为$customer。customer的结果如下

HTTP/1.1 201 Created
Date: Wed,11 Nov 2020 13:01:45 GMT
Content-Type: application/json
Content-Length: 656
Connection: keep-alive
Set-Cookie: __cfduid=d0b3005ad0a12f77a2c90d415299a67b81605099705; expires=Fri,11-Dec-20 13:01:45 GMT; path=/; domain=.waveapps.com; HttpOnly; SameSite=Lax; Secure
Set-Cookie: AWSALB=UN0XCFMkT2N0J9s1zV8rT7DnX2602qwovF7WuI8dfGw7hQdd/m0sTpQKnj2LDQZHEt04qfdWCE4IdzHVUbf+3sYGPXAIXtXLlOYv3rfMyz+m0pdgp4ydwocgztrR; Expires=Wed,18 Nov 2020 13:01:45 GMT; Path=/
Set-Cookie: AWSALBCORS=UN0XCFMkT2N0J9s1zV8rT7DnX2602qwovF7WuI8dfGw7hQdd/m0sTpQKnj2LDQZHEt04qfdWCE4IdzHVUbf+3sYGPXAIXtXLlOYv3rfMyz+m0pdgp4ydwocgztrR; Expires=Wed,18 Nov 2020 13:01:45 GMT; Path=/; SameSite=None; Secure
Allow: GET,POST,HEAD,OPTIONS
X-Client-Id: zUUT6X7oVQ.fV_DR.65QGl9X8aZluRjJVI1G-v-6
X-Wave-API-Version: 1
vary: Origin,Cookie
Expires: Wed,11 Nov 2020 13:01:44 GMT
Cache-Control: no-cache
Pragma: no-cache
CF-Cache-Status: DYNAMIC
cf-request-id: 0658feeaea00007f1181a8b000000001
Expect-CT: max-age=604800,report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Strict-Transport-Security: max-age=7776000; includeSubDomains
X-Content-Type-Options: nosniff
Server: cloudflare
CF-RAY: 5f083424adcb7f11-CMB

{"id":46437620,"url":"https://api.waveapps.com/businesses/customers/46437620/","account_number":"","active":true,"name":"ddddd xxxxx","first_name":"","last_name":"","email":"ttttt@t.lk","fax_number":"","mobile_number":"","phone_number":"","toll_free_number":"","website":"","internal_notes":"","currency":{"url":"https://api.waveapps.com/currencies/SGD/","code":"SGD","symbol":"$","name":"Singapore dollar","plural":null},"address1":"","address2":"","city":"","province":null,"country":null,"postal_code":"","date_created":"2020-11-11T13:01:45+00:00","date_modified":"2020-11-11T13:01:45+00:00","shipping_details":null}

我需要获取上述结果的ID。请帮助

在我的终端中为var_dump($ customer)得到以下结果

string(1910) "HTTP/1.1 201 Created
Date: Wed,11 Nov 2020 15:12:23 GMT
Content-Type: application/json
Content-Length: 659
Connection: keep-alive
Set-Cookie: __cfduid=d4340d399a0ff44e41c51062a9baca52f1605107542; expires=Fri,11-Dec-20 15:12:22 GMT; path=/; domain=.waveapps.com; HttpOnly; SameSite=Lax; Secure
Set-Cookie: AWSALB=4BtBF6k5ldc1RuDHRZP1CXNqi4dGJk2pyO5LLeZSwiLU12A0k9Ah71KZtGSCjgQpQmhVAbPPuYbxt72kgOJ8+Jt5asPIYBziSz+ru8yKxz8fO73rVpcwzVNerxoh; Expires=Wed,18 Nov 2020 15:12:22 GMT; Path=/
Set-Cookie: AWSALBC"...

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)