对于纯朴缘故,我已经切断了大部分这种应答串抓住所有字符串后的特定字符
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 06 Oct 2016 17:16:58 GMT
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
X-Rate-Limit-Limit: 300
X-Rate-Limit-Remaining: 297
X-Rate-Limit-Reset: 24
Strict-Transport-Security: max-age=86400 { "status" : 200, "requestId" : "0290bc44-ee91-44b5-8a4e-d2abde77dda2", "likelihood" : 0.89, "photos" : [ { "type" : "facebook", "typeId" : "facebook", "typeName" : "Facebook", "url" : "https://d2ojpxxtu63wzl.cloudfront.net/static/354316d570e9a875994ebace97f5c499_aadb87c0d5bfdca27ec6d9de1467b45856e2d1e9d5aba04a50cfaa76c0887dd9", "isPrimary" : true }, { "type" : "linkedin", "typeId" : "linkedin", "typeName" : "LinkedIn", "url" : "https://d2ojpxxtu63wzl.cloudfront.net/static/fbb7ab1a477ac0721fa1b6343e65cda8_69b2ec8691007604f741862a51146ab259c689db392a21ab3df697248df68d17" }, { "type" : "google", "typeId" : "google", "typeName" : "GooglePlus", "url" : "https://d2ojpxxtu63wzl.cloudfront.net/static/f08e1cdd3673736fe94a131eb02d5cf2_1d48402d2de6af8479415653cb1f2eb52a715650862e50a6bcac0a6477e32a07" }, { "type" : "gravatar", "typeId" : "gravatar", "typeName" : "Gravatar", "url" : "https://d2ojpxxtu63wzl.cloudfront.net/static/da16a86493fdb3ab77238be7ac5161e6_33ad1223f2c4813fe954eb33cf2f9f3b2cd597b7331be6b53646dd9dd0e68152" },
的我抓住,我需要在使用PHP这个请求的HTTP标头。后面的话我需要抓住一切减去http标题返回并使用。我曾试着使用substr()
在一定数量的字符(头部结尾)后剪切并使用所有内容,但由于在确切数量的字符之后将其切断,并且HTTP请求随时可能发生更改,因此它已被证明不可信。我期望正则表达式将是这个关键,但我希望有任何有用的方法来解决这个问题。我将需要在max-age = 86400之后切断字符串。之后,一切都将需要解析
你可能无法得到不需要的标题(只是身体)在这是来自哪些代码。否则只是分裂在第一次“{” – nogad
你用什么来获取这些数据?它看起来可能会损坏。 – Phil