multipart/form-data php curl
Je suis à l'aide de la reconnaissance optique de Service de i2ocr.com pour convertir une image en texte..
Dans mon projet, j'ai besoin de faire ce travail automatiquement, donc je suis en utilisant PHP pour obtenir le texte de l'image.
Dans le ROC site web de la postdata est contenue dans le formulaire de multipart/form-data
Comme ceci:
-----------------------------32642708628732\r\n
Content-Disposition: form-data; name="i2ocr_options"\r\n
\r\n
url\r\n
-----------------------------32642708628732\r\n
Content-Disposition: form-data; name="i2ocr_uploadedfile"\r\n
\r\n
\r\n
-----------------------------32642708629732\r\n
Content-Disposition: form-data; name="i2ocr_url"\r\n
\r\n
http://www.murraydata.co.uk/wp-content/uploads/2013/02/ocr-font-500x220.jpg\r\n
-----------------------------32642708628732\r\n
Content-Disposition: form-data; name="i2ocr_languages"\r\n
\r\n
gb,eng\r\n
-----------------------------32642708628732--\r\n
En PHP, je suis en utilisant
$ch = curl_init();
$dt = array();
$dt['i2ocr_options'] = 'url';
$dt['i2ocr_uploadedfile'] = '';
$dt['i2ocr_url'] = 'http://www.murraydata.co.uk/wp-content/uploads/2013/02/ocr-font-500x220.jpg';
$dt['i2ocr_languages'] = 'gb,eng';
curl_setopt($ch, CURLOPT_URL,"http://www.i2ocr.com/process_form");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:23.0) Gecko/20100101 Firefox/23.0");
curl_setopt($ch,CURLOPT_ENCODING,"gzip,deflate");
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: multipart/form-data; boundary=---------------------------32642708628732"));
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_REFERER, "http://www.i2ocr.com/");
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "$dt");
$html=curl_exec($ch);
print_r($html);
Ce code ne génère pas d'erreurs, mais je n'ai pas toute la production ou l'autre.
J'ai besoin d'aide pour obtenir la sortie de cette demande curl.
Vous devez vous connecter pour publier un commentaire.
Comme ceci:
utilisation afficher la source pour voir la réponse html, vous pouvez voir le texte de l'image (désolé pour mon anglais). Fonctionne à 100% 🙂