我有一个使用PHP Web服务所需的值。该网络服务需要一个值的数组。所以我在Python脚本上有这个:
data = {
'resId' : res_id,
'collId' : 'letterbox_coll',
'table' : 'res_attachments',
'data' : {
'title' : 'Rapprochement note interne',
'attachment_type' : Config.cfg[_process]['attachment_type'],
'coll_id' : 'letterbox_coll',
'res_id_master' : res_id
},
'fileFormat' : Config.cfg[_process]['format'],
}
当我打印data
时,我有一个:
{'残基':'655','collid':'leetterbox_coll','table':'res_attachments','data':{'title':'Rapprochement Note Interne','eatherment_type':','Coll_id':'Letterbox_coll','res_id_master':'655'},'fileformat':'pdf'}
但这是我的php Web服务的返回:
Array
(
[resId] => 655
[collId] => letterbox_coll
[table] => res_attachments
[data] => res_id_master
[fileFormat] => pdf
)
PHP WS使用http请求的纤细框架和此框架的响应,这是一个代码:
use AttachmentmodelsAttachmentModel;
use ConvertcontrollersConvertPdfController;
use ConvertcontrollersConvertThumbnailController;
use ConvertmodelsAdrModel;
use DocservermodelsDocserverModel;
use DocservermodelsDocserverTypeModel;
use HistorycontrollersHistoryController;
use ResourcecontrollersResController;
use RespectValidationValidator;
use setasignFpdiTcpdfFpdi;
use SlimHttpRequest;
use SlimHttpResponse;
use SrcCoremodelsCoreConfigModel;
use ResourcecontrollersStoreController;
use TemplatecontrollersTemplateController;
use SrcCoremodelsDatabaseModel;
use ResourcemodelsResModel;
class AttachmentController
{
public function create(Request $request, Response $response)
{
$data = $request->getParams();
file_put_contents('/var/www/html/test.txt', print_r($request, true));
所以我的问题是,为什么PHP会检索这样的"数据"索引?以及我如何发送数组?
预先感谢
print_r()
命令输出。https://www.php.net/manual/en/function.print-r.php
看起来您有一个数组。您是否希望以JSON格式保存数组,只需执行以下
$json = json_encode($someArray);
https://www.php.net/manual/en/function.json-encode.php