休息敏捷性中不需要的响应文本
unwanted response text in rest apigility
使用 apigility 在 postman 中获得 json 响应
当我在 postman 中发送 post 请求并像这样 return 响应时
{
"\u0000*\u0000version": null,
"\u0000*\u0000contentSent": false,
"\u0000*\u0000recommendedReasonPhrases": {
"100": "Continue",
"101": "Switching Protocols",
"102": "Processing",
"200": "OK",
"201": "Created",
"202": "Accepted",
"203": "Non-Authoritative Information",
"204": "No Content",
"205": "Reset Content",
"206": "Partial Content",
.
.
.
"508": "Loop Detected",
"511": "Network Authentication Required"
},
"\u0000*\u0000statusCode": 200,
"\u0000*\u0000reasonPhrase": null,
"\u0000*\u0000headers": {},
"\u0000*\u0000metadata": [],
"\u0000*\u0000content": "{\"success\":\"this is test\"}",
"_links": {
"self": {
"href": "http://xxxxx/xxxxx/public/userapi"
}
}
我在 userapiresource.php 中的代码,使用获取 table 数据和 return 它也像这样输出
public function create($data)
{
$response=new HttpResponse;
$response->setContent(\Zend\Json\Json::encode(array('success'=>"this is test")));
return $response;
}
在 return 敏捷响应中得到它:
所以在 userapiResource.php
中更改我的代码
public function create($data)
{
$client = new Client();
$client->setUri('http://xxxx/xxxx/public/mob-app/client/update');
// set some parameters
$client->setParameterPost(array('userid'=> $data->userid,'price'=>$data->price));
// POST request
$client->setMethod('POST');
$respons=$client->send();
$respons->getContent();
$returnArray = [];
$final_array = [
'content' => json_decode($respons->getContent())
];
$returnArray['data'] = $final_array;
$returnArray['success'] = 'true';
$returnArray['reason'] = '';
return $returnArray;
}
使用 apigility 在 postman 中获得 json 响应 当我在 postman 中发送 post 请求并像这样 return 响应时
{
"\u0000*\u0000version": null,
"\u0000*\u0000contentSent": false,
"\u0000*\u0000recommendedReasonPhrases": {
"100": "Continue",
"101": "Switching Protocols",
"102": "Processing",
"200": "OK",
"201": "Created",
"202": "Accepted",
"203": "Non-Authoritative Information",
"204": "No Content",
"205": "Reset Content",
"206": "Partial Content",
.
.
.
"508": "Loop Detected",
"511": "Network Authentication Required"
},
"\u0000*\u0000statusCode": 200,
"\u0000*\u0000reasonPhrase": null,
"\u0000*\u0000headers": {},
"\u0000*\u0000metadata": [],
"\u0000*\u0000content": "{\"success\":\"this is test\"}",
"_links": {
"self": {
"href": "http://xxxxx/xxxxx/public/userapi"
}
}
我在 userapiresource.php 中的代码,使用获取 table 数据和 return 它也像这样输出
public function create($data)
{
$response=new HttpResponse;
$response->setContent(\Zend\Json\Json::encode(array('success'=>"this is test")));
return $response;
}
在 return 敏捷响应中得到它: 所以在 userapiResource.php
中更改我的代码public function create($data)
{
$client = new Client();
$client->setUri('http://xxxx/xxxx/public/mob-app/client/update');
// set some parameters
$client->setParameterPost(array('userid'=> $data->userid,'price'=>$data->price));
// POST request
$client->setMethod('POST');
$respons=$client->send();
$respons->getContent();
$returnArray = [];
$final_array = [
'content' => json_decode($respons->getContent())
];
$returnArray['data'] = $final_array;
$returnArray['success'] = 'true';
$returnArray['reason'] = '';
return $returnArray;
}