我正在使用广告系列监视器的api 并尝试以json
格式检索响应,它应该执行此操作。我回应了回应,这是一个例子:
string(342) "HTTP/1.1 400 Bad Request
Server: csw
Cache-Control: private, s-maxage=0
X-CS-Node: 25
Content-Type: application/json; charset=utf-8
P3P: CP="OTI DSP COR CUR IVD CONi OTPi OUR IND UNI STA PRE"
Date: Sun, 27 Jan 2013 12:35:10 GMT
Connection: close
Content-Length: 66
{"Code":250,"Message":"List title must be unique within a client"}"
我想获得唯一的最后一行。我怎样才能做到这一点 ? (我尝试用空格来爆炸响应,但它没有改变任何东西)。
修改:文档为here,我调用方法method()
,返回响应$response = method()
并运行echo($response)
答案 0 :(得分:0)
您可以使用preg_match函数通过搜索正则表达式'/ {。*} /'来搜索JSON。
preg_match('/\{.*\}/', $response, $matches);
答案 1 :(得分:0)
基于this example code,您应该这样做:
$result = method(); # I'm assuming you over-simplified the code in your question and "method" isn't the real method name
echo $result->response; # Not echo $result;