Ejemplo n.º 1
0
 /**
  * 获取JSSDK的配置数组.
  *
  * @param array $APIs
  * @param bool  $debug
  * @param bool  $json
  *
  * @return string|array
  */
 public function config(array $APIs, $debug = false, $beta = false, $json = true)
 {
     $signPackage = $this->getSignaturePackage();
     $base = array('debug' => $debug, 'beta' => $beta);
     $config = array_merge($base, $signPackage, array('jsApiList' => $APIs));
     return $json ? JSON::encode($config) : $config;
 }
Ejemplo n.º 2
0
 /**
  * 返回json.
  *
  * @return string
  */
 public function toJson()
 {
     return JSON::encode($this->all());
 }
Ejemplo n.º 3
0
 /**
  * 获取配置文件(用于 Jssdk chooseWXPay 方式).
  * 
  * @param bool|true $asJson
  *
  * @return array|string
  */
 public function getConfigJssdk($asJson = true)
 {
     $config = $this->generateConfig();
     $params = array('timestamp' => $config['timeStamp'], 'nonceStr' => $config['nonceStr'], 'package' => $config['package'], 'signType' => $config['signType'], 'paySign' => $config['paySign']);
     return $asJson ? JSON::encode($params) : $params;
 }
Ejemplo n.º 4
0
 /**
  * 上传视频.
  *
  * 有点不一样。。。
  *
  * @param string $path
  * @param string $title
  * @param string $description
  *
  * @return string
  */
 public function video($path, $title, $description)
 {
     $params = array('description' => JSON::encode(array('title' => $title, 'introduction' => $description)));
     return $this->upload('video', $path, $params);
 }
Ejemplo n.º 5
0
 /**
  * 生成 js添加到卡包 需要的 card_list 项.
  *
  * @param string $cardId
  * @param array  $extension
  *
  * @return string
  */
 public function attachExtension($cardId, array $extension = array())
 {
     $timestamp = time();
     $ext = array('code' => Arr::get($extension, 'code'), 'openid' => Arr::get($extension, 'openid', Arr::get($extension, 'open_id')), 'timestamp' => $timestamp, 'outer_id' => Arr::get($extension, 'outer_id'), 'balance' => Arr::get($extension, 'balance'));
     $ext['signature'] = $this->getSignature($this->getTicket(), $timestamp, $cardId, $ext['code'], $ext['openid'], $ext['balance']);
     return array('cardId' => $cardId, 'cardExt' => JSON::encode($ext));
 }