xml地图|网站地图|网站标签 [设为首页] [加入收藏]

澳门皇家赌场在线文字识别api

来源:http://www.ccidsi.com 作者:呼叫中心培训课程 人气:103 发布时间:2020-01-31
摘要:1.ceshi.php ?php/** * 发起http post请求, 并获取REST请求的结果* @param string $url* @param string $param* @return - http response body if succeeds, else false.*/header("Content-Type: text/html; charset=UTF-8");function request_po

1.ceshi.php

<?php/** * 发起http post请求, 并获取REST请求的结果* @param string $url* @param string $param* @return - http response body if succeeds, else false.*/header("Content-Type: text/html; charset=UTF-8");function request_post($url = '', $param = ''){ if (empty || empty { return false; } $postUrl = $url; $curlPost = $param; // 初始化curl $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $postUrl); curl_setopt($curl, CURLOPT_HEADER, 0); // 要求结果为字符串且输出到屏幕上 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // post提交方式 curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost); // 运行curl $data = curl_exec; curl_close; return $data;}//获取access_tokeninclude 'curl.php';$curl = new Curl();$access_token = $curl->access_token();//定义参数并去请求api $url = 'https://aip.baidubce.com/rest/2.0/ocr/v1/general?access_token=' . $access_token;$img = file_get_contents;$img = base64_encode;$bodys = array( "image" => $img);$data = json_decode(request_post($url, $bodys));//解码json数据//重定义数据$arr = array();foreach ($data->words_result as $k=>&$v){ $arr[]=$v->words;}//转换成字符串var_dump(json_encode;

2.curl.php

<?php class Curl{ public function _request($curl, $https = true,$method='GET',$data = null){ $ch = curl_init();//初始化curl curl_setopt($ch, CURLOPT_URL, $curl); curl_setopt($ch, CURLOPT_HEADER, FALSE);//CURLOPT_HEADER 设置头部 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);//设置内容 if{ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);//是否进行服务器主机验证 不验证 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);//是否验证证书 验证 if($method == 'POST'){ curl_setopt($ch,CURLOPT_POST , true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data);//设置数据 } $content = curl_exec;//得到一个值 curl_close;//关闭资源 释放 return $content;//返回得到的值 } } /** * 获取API访问授权码 * @param ak: ak from baidu cloud app * @param sk: sk from baidu cloud app * @return - access_token string if succeeds, else false. */ public function access_token(){ //密钥 $ak = 'HPxjQ2nR0ClpNG9sXWBqGp47'; $sk = 'n7wsd5Le0hFExb5G2gs0LptPAdSeDUPR'; //请求地址 $url = 'https://aip.baidubce.com/oauth/2.0/token'; //参数 $post_data = array(); $post_data['grant_type'] = 'client_credentials'; $post_data['client_id'] = $ak; $post_data['client_secret'] = $sk; //请求方法 $res = $this->_request($url,true,'POST',$post_data); $res = json_decode($res, true); return $res['access_token']; }}?>

本文由68399皇家赌场发布于呼叫中心培训课程,转载请注明出处:澳门皇家赌场在线文字识别api

关键词: 68399皇家赌场 php 文字 AI

上一篇:论文笔记,目标检测

下一篇:没有了

频道精选

最火资讯