绑定域名& 引入js
https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115 参考文档步骤1,步骤2
设置ip白名单
在 基本配置
->ip白名单
将服务器Ip配置好即可
生成分享配置
将下面代码加入项目
<?php
class WxShare
{
private $appId;
private $appSecret;
public function __construct($appId = '自己的appid', $appSecret = '自己的appSecret')
{
$this->appId = $appId;
$this->appSecret = $appSecret;
}
public function getSignPackage()
{
//接收到前端的转义url转义回来
$url = $_POST;
$durl = $url['url'];
$durl = urldecode($durl);
$jsapiTicket = $this->getJsApiTicket();
var_dump($jsapiTicket);
$timestamp = time();
$nonceStr = $this->createNonceStr();
// 这里参数的顺序要按照 key 值 ASCII 码升序排序
$string = "jsapi_ticket=$jsapiTicket&noncestr=$nonceStr×tamp=$timestamp&url=$durl";
$signature = sha1($string);
$signPackage = [
"appId" => $this->appId,
"nonceStr" => $nonceStr,
"timestamp" => $timestamp,
"url" => $url,
"signature" => $signature,
"rawString" => $string
];
// var_dump($signPackage);die;
return $signPackage;
}
public function curlGet($url) {
$curl = curl_init(); // 启动一个C