ShareServer.class.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Common\Server;
  3. class ShareServer {
  4. const type_wx = 'wx';
  5. const type_qq = 'qq';
  6. const type_wb = 'wb';
  7. /**
  8. * 获取分享数据
  9. * @author: linch
  10. */
  11. public function get_share_config() {
  12. $config = array(
  13. 'type' => 'wx',
  14. 'wx' => array(
  15. "appId" => '',
  16. "nonceStr" => '',
  17. "timestamp" => '',
  18. "url" => '',
  19. "signature" => '',
  20. "rawString" => '',
  21. ),
  22. );
  23. if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ) {
  24. $config['type'] = self::type_wx;
  25. }
  26. // if ( stripos($_SERVER['HTTP_USER_AGENT'], 'qq') !== false ) {
  27. // $config['type'] = self::type_qq;
  28. // }
  29. //
  30. // if ( stripos($_SERVER['HTTP_USER_AGENT'], 'weibo') !== false ) {
  31. // $config['type'] = self::type_wb;
  32. // }
  33. if ($config['type'] == self::type_wx) {
  34. $APPID = \Common\Common\share\WxShareServer::APPID;
  35. $APPSECRET = \Common\Common\share\WxShareServer::APPSECRET;
  36. $wxShare = new \Common\Common\share\WxShareServer($APPID, $APPSECRET);
  37. $wx_config = $wxShare->getSignPackage();
  38. $config['wx'] = $wx_config;
  39. }
  40. return $config;
  41. }
  42. }