18/04
2017
Wallogit.com
2017 © Pedro Peláez
getwxopenid support in laravel 5.1
composer require yuxiaoyang/getwxopenid
或者在你的 composer.json 的 require 部分中添加:, (*1)
"yuxiaoyang/getwxopenid": "~1.0"
下载完毕之后,直接配置 config/app.php 的 providers:, (*2)
//Illuminate\Hashing\HashServiceProvider::class, Yuxiaoyang\GetwxOpenid\GetwxOpenidProvider::class,
控制器中使用 WxpayController.php :, (*3)
```php, (*4)
<?php, (*5)
use \Yuxiaoyang\GetwxOpenid\GetwxOpenid;, (*6)
class WxpayController extends Controller {, (*7)
public $getwxopenid;
//获取JSAPI openid
public function getopenid()
{
//创建示例对象
$this->getwxopenid = new GetwxOpenid();
$data = $this->getwxopenid->getOpenid();
return $data;
}
}, (*8)