腾讯云OCR文字识别PHP demo

2020-06-23 15:12:45 浏览数 (1)

代码语言: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);

0 人点赞