Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

post返回空数组 #120

Open
skadiD opened this issue Mar 17, 2021 · 7 comments
Open

post返回空数组 #120

skadiD opened this issue Mar 17, 2021 · 7 comments
Labels
question Further information is requested

Comments

@skadiD
Copy link

skadiD commented Mar 17, 2021

使用SaberGM post请求http://api.ttshitu.com/base64得到意外的结果(空内容)
似乎并不是contentType的问题

@sy-records
Copy link
Member

提供下复现代码和账户信息~
可以发我邮箱

@sy-records sy-records added the question Further information is requested label Mar 18, 2021
@skadiD
Copy link
Author

skadiD commented Mar 18, 2021

提供下复现代码和账户信息~
可以发我邮箱
账户信息已私发邮箱 以下为原始代码
$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);

@sy-records
Copy link
Member

$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"}}

@skadiD
Copy link
Author

skadiD commented Mar 19, 2021

感谢指点,getContents是在文档那里提示了吗?

@skadiD
Copy link
Author

skadiD commented Mar 20, 2021

@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是正常返回

@sy-records
Copy link
Member

curl代码也给个
抓包对比下

@Vany520
Copy link

Vany520 commented Jun 12, 2023

我也遇到类似的问题,不知道题主最终解决了没

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants