コード例 #1
0
    /**
     * 查看会员信息
     */
    public function getMemberCardUserInfo($data) {
        $url = sprintf(self::get_member_card_user_info, $this->_token);
        $json = code_unescaped($data);
        $result = WeiXinApiRequest::post($url, $json, false, false);
        // 写入系统日志
        $this->_debug && Factory::getSystemLog()->push("getMemberCardUserInfo  拉取会员信息(积分查询)接口:", array(
                    'data' => $data,
                    'json' => $json,
                    'result' => $result
        ));

        if ($result ['errcode'] != 0) {
            $this->error = array(
                'errcode' => $result ['errcode'],
                'errmsg' => $result ['errmsg']
            );
            return $this->error;
        }
        return $result;
    }
コード例 #2
0
	/**
	 * 获取jsapi_ticket
	 *
	 * 对应API:{@link https://api.weixin.qq.com/cgi-bin/ticket/getticket}
	 *
	 * @access public
	 * @return object WX_Token
	 */
	public function getJsApiTicket($type = 'jsapi')
	{
		$type = in_array($type, array('jsapi', 'wx_card')) ? $type : 'jsapi';
		$params = array ();
		$params['type'] = $type;
		$path = 'ticket/getticket';
		$response = WeiXinApiRequest::GET($this->_genUrl($path), $params);
		return call_user_func_array(array (
				$this,
				'_parse'
		), array (
				WeiXinApiRequest::$http_code,
				$response,
				'_parseJsApiTicket'
		));
	}
コード例 #3
0
	/**
	 * 获取用户信息
	 * @param string $openId
	 * @return WX_User
	 */
	public function getUserInfo ($openId, $accessToken = null) {
		//TODO 带实现
		if ($accessToken) {
			$this->setAccessToken($accessToken);
		}
		if (!$this->accessToken) {
			$this->_setError(WX_Error::KOTEN_MISSING_ERROR);
			return null;
		}
		$param = array(
				'access_token' => $this->accessToken,
				'openid'=> $openId,
		);
		$url = $this->_getUrl('userinfo', $param);
		$response = WeiXinApiRequest::GET($url);
		return call_user_func_array(array($this, '_parse'),
				array(WeiXinApiRequest::$http_code, $response, '_parseUser'));
	}
コード例 #4
0
    /**
     * @ignore
     */
    private static function _buildHttpQueryMulti($params)
    {
        if (!$params) return '';

        uksort($params, 'strcmp');

        $pairs = array();

        self::$boundary = $boundary = uniqid('----------');

        $MPboundary = '--'.$boundary;
        $endMPboundary = $MPboundary. '--';
        $multipartbody = '';

        foreach ($params as $param => $value) {

            if( 'media' == $param && $value{0} == '@' ) {
                $url = ltrim( $value, '@' );
                $content = file_get_contents( $url );
                $array = explode( '?', basename( $url ) );
                $filename = $array[0];

                $multipartbody .= $MPboundary . "\r\n";
                $multipartbody .= 'Content-Disposition: form-data; name="' . $param . '"; filename="' . $filename . '"'. "\r\n";
                $multipartbody .= "Content-Type: application/octet-stream\r\n\r\n";
                $multipartbody .= $content. "\r\n";
            } else {
                $multipartbody .= $MPboundary . "\r\n";
                $multipartbody .= 'Content-Disposition: form-data; name="' . $param . "\"\r\n\r\n";
                $multipartbody .= $value."\r\n";
            }

        }

        $multipartbody .= $endMPboundary;
        return $multipartbody;
    }
コード例 #5
0
	public function code_info($code, $card_id) {
		$url = sprintf(self::code_info, $this->token);
		
		$json = code_unescaped(array('code'=>$code, 'card_id'=>$card_id));
		$result = WeiXinApiRequest::post($url, $json, false, false);
		
		//写入系统日志
		$this->debug && Factory::getSystemLog()->push("CardPacket code_info获取卡券领取信息:", array('code'=>$code, 'card_id'=>$card_id, 'result'=>$result));
		
		if($result['errcode']==0){
			return $result['openid'];
		}
		
		return FALSE;
	}
コード例 #6
0
	/**
	 * 解密code
	 * https://api.weixin.qq.com/card/code/decrypt?access_token=TOKEN
	 * @param string $encrypt_code 加密的code
	 * @return string $decrypt_code 
	 */
	public function decryptCode($encrypt_code)
	{
		// 参数验证
		if (empty($encrypt_code)) {
			return false;
		}
		$param = array(
				'$encrypt_code' => $encrypt_code,
		);
		$url = $this->_getUrl('card/code/decrypt');
		// WeiXinApiRequest::$debug = 1;
		$json = new Json();
		$param = $json->encode($param, false);
		$response = WeiXinApiRequest::post($url, $param);
		return call_user_func_array(array(
				$this,
				'_parse'
		), array(
				WeiXinApiRequest::$http_code,
				$response,
				'_parseDecryptCode'
		));
	}