Inheritance: extends BaseService
Esempio n. 1
0
<?php

require __DIR__ . '/../vendor/autoload.php';
$config = array('appId' => 'wx00e5904efes9', 'appSecret' => '419ffc73eb1fga846c6b04b', 'token' => '54b780cbe9047', 'encodingAesKey' => 'cz7NR8g4vk5yMydpG3g8amyFGbjavCuR33', 'mchId' => '1220633201', 'apiSecret' => 'b4944959c6eaed319a86e3a10d');
// 初始化SDK
\PFinal\Wechat\Kernel::init($config);
// 获取OpenID
$openid = \PFinal\Wechat\Service\OAuthService::getOpenid();
//$openid='oU3OCt5O46PumN7IE87WcoYZY9r0';
// JS签名
$signPackage = \PFinal\Wechat\Service\JsService::getSignPackage();
// 支付成功通知url
/* 收到支付成功通知时,请使用下面的方法,验证订单号和支付金额
    $info = \PFinal\Wechat\Service\PayService::notify();
    $info数组,内容如下
    [
         mch_id          //微信支付分配的商户号
         appid           //微信分配的公众账号ID
         openid          //用户在商户appid下的唯一标识
         transaction_id  //微信支付订单号
         out_trade_no    //商户订单号
         total_fee       //订单总金额单位默认为分,已转为元
         is_subscribe    //用户是否关注公众账号,Y-关注,N-未关注,仅在公众账号类型支付有效
         attach          //商家数据包,原样返回
         time_end        //支付完成时间
    ]
*/
$notifyUrl = 'http://xxx.com/index.php/wxpay/notify';
// 订单信息
$order = array('totalFee' => 0.01, 'tradeNo' => uniqid(), 'name' => '测试订单');
// 业务签名
Esempio n. 2
0
File: mp.php Progetto: pfinal/wechat
    //$arr = \PFinal\Wechat\Service\MaterialService::uploadFile('./video.mp4', 'video', '测试', '描述');
    //var_dump($arr);
    //var_dump(\PFinal\Wechat\Service\MessageService::send($openid2, new \PFinal\Wechat\Message\Video($videoMediaId, $imageMediaId, 'aa', 'bb')));
    exit;
}
if (isset($_GET['token'])) {
    echo $api->getAccessToken(false);
    //不使用缓存,直接从服务器获取token
    exit;
}
if (isset($_GET['openid'])) {
    echo \PFinal\Wechat\Service\OAuthService::getOpenid();
    exit;
}
if (isset($_GET['user'])) {
    $user = \PFinal\Wechat\Service\OAuthService::getUser();
    var_dump($user);
    exit;
}
if (isset($_GET['send'])) {
    $result = \PFinal\Wechat\Service\MessageService::send($openid2, new \PFinal\Wechat\Message\Text('test'));
    var_dump($result);
    exit;
}
if (isset($_GET['preview'])) {
    //$result = \PFinal\Wechat\Service\MessageService::previewWithWxname('rainphp',new \PFinal\Wechat\Message\Text('test'));
    //$result = \PFinal\Wechat\Service\MessageService::previewWithWxname('rainphp',new \PFinal\Wechat\Message\Image($imageMediaId));
    //$result = \PFinal\Wechat\Service\MessageService::previewWithWxname('rainphp',new \PFinal\Wechat\Message\Voice($voiceMediaId));
    //$result = \PFinal\Wechat\Service\MessageService::previewWithWxname('rainphp',new \PFinal\Wechat\Message\MpNews($newsMediaId));
    $result = \PFinal\Wechat\Service\MaterialService::uploadFile('./voice.mp3', 'music');
    var_dump($result);