Open skadiD opened 3 years ago
提供下复现代码和账户信息~ 可以发我邮箱
提供下复现代码和账户信息~ 可以发我邮箱 账户信息已私发邮箱 以下为原始代码
$Api = Saber::create([ 'use_pool' => true, 'base_uri' => 'http://api.ttshitu.com', 'headers' => [ 'Content-Type' => ContentType::JSON, ] ]); $ret = $Api->post('/base64', [ 'username' => 'skadi', 'password' => '', 'typeid' => 1001, 'image' => '' ])->body; print_r($ret);
$ret = $Api->post('/base64', [ 'username' => 'skadi', 'password' => '', 'typeid' => 1001, 'image' => '' ])->body;
print_r($ret->getContents());
这里是有数据的啊?
{"success":true,"code":"0","message":"success","data":{"result":"9349","id":"Zx3KeRNZQTKEXKbXg_niEQ"}}
感谢指点,getContents是在文档那里提示了吗?
@sy-records 发现问题的根源了
似乎是saber在处理body的时候会成为
<ResultMessage><success>true</success><code>0</code><message>success</message><data><result>6939</result><id>c6228a80850e408b967535ec33658b46</id></data></ResultMessage>
使用的是$ret->getContents()
使用getParsedXmlArray()可以解析成功,但是问题是接口返回的明明是json格式的,使用curl是正常返回
curl代码也给个 抓包对比下
我也遇到类似的问题,不知道题主最终解决了没
使用SaberGM post请求http://api.ttshitu.com/base64得到意外的结果(空内容) 似乎并不是contentType的问题