日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

h5 修改title 微信_微信h5网页自定义分享(标题、描述、图标)

發布時間:2024/10/8 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 h5 修改title 微信_微信h5网页自定义分享(标题、描述、图标) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

$this->appId =$appId;

$this->appSecret =$appSecret;

}publicfunction getSignPackage() {

$jsapiTicket= $this->getJsApiTicket();//注意 URL 一定要動態獲取,不能 hardcode.

$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";

$url= "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

$timestamp=time();

$nonceStr= $this->createNonceStr();//這里參數的順序要按照 key 值 ASCII 碼升序排序

$string = "jsapi_ticket=$jsapiTicket&noncestr=$nonceStr&timestamp=$timestamp&url=$url";

$signature= sha1($string);

$signPackage=array("appId" => $this->appId,"nonceStr" =>$nonceStr,"timestamp" =>$timestamp,"url" =>$url,"signature" =>$signature,"rawString" => $string);return$signPackage;

}private function createNonceStr($length = 16) {

$chars= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

$str= "";for ($i = 0; $i < $length; $i++) {

$str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);

}return$str;

}privatefunction getJsApiTicket() {//jsapi_ticket 應該全局存儲與更新,以下代碼以寫入到文件中做示例

$data = json_decode($this->get_php_file("jsapi_ticket.php"));if ($data->expire_time

$accessToken= $this->getAccessToken();//如果是企業號用以下 URL 獲取 ticket//$url = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token=$accessToken";

$url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=$accessToken";

$res= json_decode($this->httpGet($url));

$ticket= $res->ticket;if($ticket) {

$data->expire_time = time() + 7000;

$data->jsapi_ticket =$ticket;

$this->set_php_file("jsapi_ticket.php", json_encode($data));

}

}else{

$ticket= $data->jsapi_ticket;

}return$ticket;

}privatefunction getAccessToken() {//access_token 應該全局存儲與更新,以下代碼以寫入到文件中做示例

$data = json_decode($this->get_php_file("access_token.php"));if ($data->expire_time appId&corpsecret=$this->appSecret";

$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$this->appId&secret=$this->appSecret";

$res= json_decode($this->httpGet($url));

$access_token= $res->access_token;if($access_token) {

$data->expire_time = time() + 7000;

$data->access_token =$access_token;

$this->set_php_file("access_token.php", json_encode($data));

}

}else{

$access_token= $data->access_token;

}return$access_token;

}privatefunction httpGet($url) {

$curl=curl_init();

curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);

curl_setopt($curl, CURLOPT_TIMEOUT,500);//為保證第三方服務器與微信服務器之間數據傳輸的安全性,所有微信接口采用https方式調用,必須使用下面2行代碼打開ssl安全校驗。//如果在部署過程中代碼在此處驗證失敗,請到http://curl.haxx.se/ca/cacert.pem下載新的證書判別文件。

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);

curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,true);

curl_setopt($curl, CURLOPT_URL, $url);

$res=curl_exec($curl);

curl_close($curl);return$res;

}privatefunction get_php_file($filename) {return trim(substr(file_get_contents($filename), 15));

}privatefunction set_php_file($filename, $content) {

$fp= fopen($filename, "w");

fwrite($fp,"<?php exit();?>". $content);

fclose($fp);

}

}

總結

以上是生活随笔為你收集整理的h5 修改title 微信_微信h5网页自定义分享(标题、描述、图标)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。