CURL帖子无法将csv数据上传到blaynmail

时间:2018-06-06 03:34:10

标签: php csv curl file-upload

$file = "blaynmailhahaha.csv";
$authorization = "Authorization: Bearer [".$response."]";

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://api.toku-maga.com/rest/1.0/contact/import/create");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); // use HTTP/1.0 instead of 1.1
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // uncomment this line if you get no gateway 
curl_setopt($curl, CURLOPT_HTTPHEADER, [$authorization, 'Content-Type: text/plain']);
$cfile = new CurlFile($file,  'text/csv','import');
//curl file itself return the realpath with prefix of @

$data = array('data-binary' => $cfile);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$curl_response = curl_exec($curl);
curl_close($curl);

var_dump($cfile);
//echo "<br>Data File  : " . $cfile ;
echo "<br>This is Access_token : " . $authorization ;
echo "<br>This is 2nd Output : " . $curl_response ;

我没有从$ curl_response得到任何回复,也无法将其上传到blaynmail。请帮我解决这个问题。

0 个答案:

没有答案