本文目錄一覽:
- 1、求個藍奏雲直連解析介面,或者是源碼。
- 2、請教php大神,如何提取一個json數據里的某值?
- 3、php用戶註冊源碼,及file_get_contents json_decode的用法~ 能幫忙解決加送200分
- 4、有沒有微信小程序調用百度ai車輛識別介面的程序源碼,很簡單的就可以?
- 5、PHP微信公眾平台自定義菜單響應事件,想知道如何才能通過key值點擊響應(回復內容或者鏈接)源碼如下
求個藍奏雲直連解析介面,或者是源碼。
介面和源碼我都有。
源碼我不知道有沒有用,因為沒php環境,不過以前測試過是可以用的!
1,介面地址:放個圖片你們自己看。
2,源碼地址 :就是上面這個介面的源碼
?php
function MloocCurl($url,$method,$ifurl,$post_data){
$UserAgent = ‘Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36’;#設置ua
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
if ($method == “post”) {
curl_setopt($curl, CURLOPT_REFERER, $ifurl);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
}
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
if (!empty($_GET[‘url’])) {
$url = $_GET[‘url’];
#第一步
$ruleMatchDetailInList = “~ifr2\”\sname=\”[\s\S]*?\”\ssrc=\”\/(.*?)\”~”;
preg_match($ruleMatchDetailInList, MloocCurl($url,null,null,null),$link);
$ifurl = “”.$link[1];
#第二步
$ruleMatchDetailInList = “~=\s'(.*?)’;[\S\s]*?=\s'(.*?)'[\S\s]*?=\s'(.*?)'[\S\s]*?=\s'(.*?)’~”;
preg_match($ruleMatchDetailInList, MloocCurl($ifurl,null,null,null),$segment);
#第三步
#post提交的數據
$post_data = array(
“action” = $segment[1],
“file_id” = $segment[2],
“t” = $segment[3],
“k” = $segment[4]
);
$obj = json_decode(MloocCurl(“”,”post”,$ifurl,$post_data));#json解析
if ($obj-dom == “”) {#判斷鏈接是否正確
echo “鏈接有誤!”;
}else{
$downUrl = $obj-dom.”/file/”.$obj-url.”/type=down/”;
if (!empty($_GET[‘type’])) {
$type = $_GET[‘type’];
if ($type == “down”) {
header(‘Location:’.$downUrl);#直接下載
}else{
header(‘Location:’.$downUrl);#直接下載
}
}else{
header(‘Location:’.$downUrl);#直接下載
}
}
}else{
$result_url = str_replace(“index.php”,””,”//”.$_SERVER[‘HTTP_HOST’].$_SERVER[‘PHP_SELF’].””);
echo “藍奏雲直連下載”;
echo “br/”;
/*echo “直接下載:”.”a href='”.$result_url.”type=down’ target=’_blank'”.$result_url.”type=down/a”;
echo “br/”;
echo “輸出直鏈:”.”a href='”.$result_url.”‘ target=’_blank'”.$result_url.”/a”;*/
}
?
請教php大神,如何提取一個json數據里的某值?
這個問題很簡單,在php里json格式就是字元串,可以用php內置函數json_decode($json,true)轉化成數組,取數組的值你應該知道怎麼弄了吧
php用戶註冊源碼,及file_get_contents json_decode的用法~ 能幫忙解決加送200分
我猜,他不一定是將那些內容加密,有可能是將數據,使用系統自定義的json函數將其格式話而已。這樣方便伺服器端的動態語言與js交互。
json_decode就是將字元串變回數據集(如數組之類),翻翻幫助手冊。
你想通過file_get_contents來拿那個列表,我到那裡觀察下,我覺得應該口口他的js,看清楚怎麼拿到數據再下手,你提問中的地址,用這種方法拿不到數據吧?
我這裡討論下,好像對你沒太大幫助,唉,水平有限。
頁面中通過js來更新stations_div的內容,顯示信息。
有沒有微信小程序調用百度ai車輛識別介面的程序源碼,很簡單的就可以?
class BaiDuAiBaseController extends BaseController
{
private $appid;
private $appKey;
private $secretKey;
public function __construct(){
$this-appid= config(‘api.baidu.appid’);
$this-appKey = config(‘api.baidu.apikey’);
$this-secretKey = config(‘api.baidu.secretkey’);
}
//百度ai介面–文字識別–車牌號識別
public function getCarNumber($_imgurl,$_img=”){
$_token = $this-getToken();
$_url = ”.$_token;
if($_img){
$_data = [
‘image’=$_img//圖像數據,base64編碼後進行urlencode,要求base64編碼和urlencode後大小不超過4M,最短邊至少15px,最長邊最大4096px,支持jpg/jpeg/png/bmp格式
];
}else{
$_data = [
‘url’=request()-domain().’/’.$_imgurl
];
}
$_res = json_decode(httpGet($_url,$_data),true);
//TODO 此處只返回false沒有終止,是因為程序執行流程需要,後期可能要改
if(isset($_res[‘error_msg’])) return false;
return $_res[‘words_result’][‘number’];
}
//獲取token
private function getToken(){
if(cache(‘baidu_token’)){
$_access_token = cache(‘baidu_token’);
}else{
$_url = ‘;client_id=’.$this-appKey.’client_secret=’.$this-secretKey;
$res = json_decode(httpGet($_url),true);
if(isset($res[‘error’]))TApiException($res[‘error_description’]);//終止程序並拋出異常
$_access_token = $res[‘access_token’];
$_expires_in = $res[‘expires_in’];
cache(‘baidu_token’,$_access_token,($_expires_in-1000));//我喜歡少存1000秒,沒有為什麼,問就是癖好
}
return $_access_token;
}
}
這是ThinkPhp5.1後端封裝的百度AI介面類,getToken()獲取憑證,getCarNumber()請求$_url 返回識別結果,這個是車牌號碼識別,車型識別等其他介面大部分都一樣,就換個請求地址$_url就行
//介面:
public function getImgCarNum(){
$_number = (new BaiDuAiBaseController())-getCarNumber(false,request()-param(‘img’));
return self::myShow(‘申請成功’,[‘carNum’=$_number]);
}
小程序端正常request請求上面的介面就行,下面是微信小程序拍照識別功能
//拍照
goImgSearch(){
uni.chooseImage({
count:1,
sizeType: [‘compressed’],//original 原圖,compressed 壓縮圖
sourceType: [‘album’,’camera’],//camera 相機 album相冊
success:(r)={
console.log(r)
//執行識別車牌號碼
this.img = r.tempFilePaths[0]
this.urlTobase64(r.tempFilePaths[0])
}
})
},
//識別車牌號碼
urlTobase64(url){
uni.showLoading({
title:’拚命識別車牌中..’
})
//#ifdef MP-WEIXIN
uni.getFileSystemManager().readFile({
filePath: url, //選擇圖片時返回的路徑
encoding: “base64”,//這個是很重要的
success: res = { //成功的回調
//返回base64格式
let base64 = ‘data:image/jpeg;base64,’ + res.data
//發送請求,識別車牌號碼
this.$H.post(‘/getImgCarNum’,{
img:base64 //圖片數據
},{
token:true //必須登錄
}).then((res)={
console.log(res.carNum)
if(!res.carNum){
uni.hideLoading()
return uni.showModal({
title:’識別失敗’,
content:’沒能識別到車牌號碼,請拍張清晰的圖片再試哦,謝謝’,
showCancel:false
})
}
uni.showToast({
title:’識別車牌成功’,
icon:’none’
})
this.searchUser = res.carNum
this.userCarNum = res.carNum
uni.hideLoading()
}).catch((e)={
uni.hideLoading()
return uni.showModal({
title:’識別失敗’,
content:’沒能識別到車牌號碼,請拍張清晰的圖片再試哦,謝謝’,
showCancel:false
})
})
},
fail:(e)={
console.log(e)
}
})
//#endif
},
PHP微信公眾平台自定義菜單響應事件,想知道如何才能通過key值點擊響應(回復內容或者鏈接)源碼如下
以下為獲取微信返回的數據
$postStr = $GLOBALS[“HTTP_RAW_POST_DATA”];//返回回複數據
if (!empty($postStr))
{
$postObj = simplexml_load_string($postStr, ‘SimpleXMLElement’, LIBXML_NOCDATA);
$this-fromUsername = $postObj-FromUserName;//發送消息方ID
$this-toUsername = $postObj-ToUserName;//接收消息方ID
$this-keyword = trim($postObj-Content);//用戶發送的消息
$this-times = time();//發送時間
$MsgType = $postObj-MsgType;//消息類型
if($MsgType==’event’) //判斷微信自定義響應事件
{
$MsgEvent = $postObj-Event;//獲取事件類型
if ($MsgEvent==’subscribe’){ //訂閱事件
#要返回的消息
}elseif ($MsgEvent==’CLICK’){ //點擊菜單
//點擊事件
$EventKey = $postObj-EventKey;//菜單的自定義的key值,可以根據此值判斷用戶點擊了什麼內容,從而推送不同信息
switch($EventKey){
case “find” : //菜單中key相關值
#返回的消息
break;
case “lock_acount”:
#返回的消息
break;
case “other”:
#返回的消息
break;
}
}
}
原創文章,作者:U7R5D,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/129752.html