12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace Common\Server;
- class ShareServer {
- const type_wx = 'wx';
- const type_qq = 'qq';
- const type_wb = 'wb';
- /**
- * 获取分享数据
- * @author: linch
- */
- public function get_share_config() {
- $config = array(
- 'type' => 'wx',
- 'wx' => array(
- "appId" => '',
- "nonceStr" => '',
- "timestamp" => '',
- "url" => '',
- "signature" => '',
- "rawString" => '',
- ),
- );
- if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ) {
- $config['type'] = self::type_wx;
- }
- // if ( stripos($_SERVER['HTTP_USER_AGENT'], 'qq') !== false ) {
- // $config['type'] = self::type_qq;
- // }
- //
- // if ( stripos($_SERVER['HTTP_USER_AGENT'], 'weibo') !== false ) {
- // $config['type'] = self::type_wb;
- // }
- if ($config['type'] == self::type_wx) {
- $APPID = \Common\Common\share\WxShareServer::APPID;
- $APPSECRET = \Common\Common\share\WxShareServer::APPSECRET;
- $wxShare = new \Common\Common\share\WxShareServer($APPID, $APPSECRET);
- $wx_config = $wxShare->getSignPackage();
- $config['wx'] = $wx_config;
- }
- return $config;
- }
- }
|