如何将这个邮递员转换为curl php?

时间:2019-07-25 07:22:15

标签: php curl postman

postmant api我在邮递员中拥有Api,但我无法更改curl php。也许有人可以帮助我

我需要像这样使用curl代码,但是我不知道如何使用curl转换主体(值数组和文件)

  curl_setopt($ch, CURLOPT_URL,"https://localhost/api/v1/clients/mobile/user");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");  
    curl_setopt($ch, CURLOPT_POSTFIELDS, **body data**);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:multipart/form-data'));
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0); 

    // receive server response ...
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $server_output = curl_exec ($ch);
    curl_close ($ch);

2 个答案:

答案 0 :(得分:1)

邮递员给您卷曲代码。

在屏幕的右上角,您获得了code并选择了php cURL

Example

答案 1 :(得分:0)

对于人们来说,我可以这样解决这个问题。登录邮递员,然后转到文档enter image description here

中的工作区和cek