【发布时间】:2020-06-04 16:32:55
【问题描述】:
我是一名 laravel 初级开发人员,我一直在使用 gazzle http 来处理我的请求,现在我的任务是将 Collections 集成到系统中。提供的 API 只希望我发布 XML 数据。当我使用 Json 时,它运行良好,但现在我的任务是通过 gazzle 发布 xml。我该怎么做。
使用 Json,
$response = $client->request('POST', 'https://app.apiproviders.com/api/payment/donate', [
'form_params' => [
'name' => 'TIG Test',
'amount' => $amount,
'number' => str_replace('+', '',$this->senders_contact),
'chanel' => 'TIG',
'referral' => str_replace('+', '',$this->senders_contact)
]
]);
the desired XML format to post:
<?xml version="1.0" encoding="UTF-8"?>
<AutoCreate>
<Request>
<Method>acdepositfunds</Method>
<NonBlocking></NonBlocking>
<Amount>500</Amount>
<Account>256702913454</Account>
<AccountProviderCode></AccountProviderCode>
<Narrative>Testing the API</Narrative>
<NarrativeFileName>receipt.doc</NarrativeFileName>
<NarrativeFileBase64>aSBhbSBwYXlpbmcgNjAwMDAgc2hpbGxpbmdz</NarrativeFileBase64>
</Request>
</AutoCreate>
how can i pass this xml to gazzle in laravel??
【问题讨论】: