Example #1
0
 public function testAction()
 {
     /*{
           "channel":"alipay_wap",
           "amount":10,
           "order_no":"no1234567890",
           "open_id":"",
           "a":1,
           "b":2
       }*/
     $url = \Pingpp\WxpubOAuth::createOauthUrlForCode($wx_app_id, $redirect_url);
     var_dump($url);
     die('333');
 }
Example #2
0
<?php

$userAgent = $_SERVER['HTTP_USER_AGENT'];
$isWechat = strpos($userAgent, 'MicroMessenger') !== false;
if ($isWechat) {
    require __DIR__ . '/../../vendor/pingplusplus/pingpp-php/init.php';
    $appId = '******************';
    $appSecret = '********************************';
    $currentUrl = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
    if (!isset($_GET['code'])) {
        $url = \Pingpp\WxpubOAuth::createOauthUrlForCode($appId, $currentUrl);
        header('Location: ' . $url);
        exit;
    } else {
        if (session_status() != PHP_SESSION_ACTIVE) {
            @session_start();
        }
        if (!isset($_SESSION['wechatOpenid'])) {
            $code = $_GET['code'];
            $_SESSION['wechatOpenid'] = \Pingpp\WxpubOAuth::getOpenid($appId, $appSecret, $code);
        }
    }
}
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <meta name="author" content="Cosmo">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
Example #3
0
 */

require_once('init.php');
require_once('initsql.php');
header("Content-Type: text/html;charset=utf-8");


//判定是否授权
$code = '';
if (isset($_GET["code"])) {
    $code = $_GET['code'];
} else {
    $callback_url = $HOST_URL . 'php/index.php';
//  $scope='snsapi_base';
//  $scope='snsapi_userinfo';//需要授权
    $url = \Pingpp\WxpubOAuth::createOauthUrlForCode($MY_APP_KEY, $callback_url, 'arr+fashioncj', false);
//    echo $url;
//    echo $callback_url;
    header("Location:" . $url);
    exit();
}

//判定推广
$state = 'arr+Main';
if (isset($_GET['state'])) {
    $state = $_GET['state'];
} else {

}

//获取open_id