因为一个TP项目中客户需要全部网页分享支持自定义图片和描述信息,于是自己封装了下
//share()微信分享链接
//参数1 appid
//参数2 appsert
//参数3 nonceStr随机码
//参数4 timestamp时间戳
public function share($appid,$appsert,$nonceStr,$timestamp){
//获取token
$token='https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$appid.'&secret='.$appsert;
$token=file_get_contents($token);
$token=json_decode($token);
$token=$token->access_token;
//获取jsapi_ticket
$ticket='https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token='.$token.'&type=jsapi';
$ticket=file_get_contents($ticket);
$ticket=json_decode($ticket);
$ticket=$ticket->ticket;
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
//获取当前域名
$url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
//返回签名
$signaturestring = "jsapi_ticket=$ticket&noncestr=$nonceStr×tamp=$timestamp&url=$url";
$signature = sha1($signaturestring);
//返回HTML页面需要的全部参数信息
return array('appid'=>$appid,'timestamp'=>$timestamp,'nonceStr'=>$nonceStr,'signature'=>$signature,'ticket'=>$ticket);
} 首先下载wkhtmltox-0.12.4_linux-generic-amd64.tar.xz (不要下载RPM包,依赖太多,需要x-server支持),并解压,执行测试运行正常tar wkhtmltox-0.12.4_linux-generic-amd64.tar.xzcd...
项目需要使用websocket推送最新订单,客户服务器非linux不支持swoole,因此使用原生,直接上代码(1).PHP服务端<?php ini_set('error_reporting', E_ALL ^ E_NOTICE); ini_set...
首先看看以下代码:代码1:<?php $a=0.1; $b=0.7; if($a+$b==0.8) { echo "1"; } else{ echo "2"; } ?>代码2:<?php &n...
源码:特别适用于微信支付中通知微信支付网关function array2xml($arr, $level = 1) { $s = $level == 1 ? "<xml&g...
php官方已经提供了Iterator(迭代器)接口,通过网上资料的学习,目前看适合超大集合或者数组提取使用。学习一个函数的实现对比内存占用差距.使用迭代器和普通循环实现range()函数。(1).普通循环实现range()函数。function newrange($low, $h...
array_merge是最常用的数组合并方法,+号同样也可以,但是却有很大不同。array_merge遇到相同字符串key,后面数组的key会覆盖前面数组的key,+号正好相反。$a = [ 'one' => 'A on...