代码语言:javascript复制
<?php
$url = "https://recognition.image.myzijiebao.com/ocr/handwriting";
// $postData = ['appid'=>"appid",'url'=>"http://test-1254540501.cosgz.myzijiebao.com/手写体.jpg"];
$image = file_get_contents('1.jpg');
$postData = ['appid'=>"appid",'image'=>$image];
$header = ['Host: recognition.image.myzijiebao.com','Content-Type: multipart/form-data','Authorization: 生成的的authorization'];
$ch = curl_init($url);
// $postData = json_encode($postData); // Content-Type: application/json
// curl_setopt($ch, CURLOPT_TIMEOUT, 8);
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$response = curl_exec($ch);
curl_close($ch);
print_r($response);