Skip to content

Commit a1feda4

Browse files
committed
init
0 parents  commit a1feda4

File tree

157 files changed

+11686
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+11686
-0
lines changed

.styleci.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
preset: symfony
2+
3+
linting: true
4+
5+
enabled:
6+
- strict
7+
- strict_param
8+
- ordered_use

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 overtrue <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# [Easy WeChat](http://easywechat.org)
2+
3+
可能是目前最优雅的微信公众平台 SDK 了。
4+
5+
> 不支持企业号,也不打算支持,原因?微信的API实在设计得太乱了,我怕累死。。。
6+
7+
SDK 使用交流 QQ 群:`319502940`
8+
9+
微信开发者交流 QQ 群:`9179779`
10+
11+
[![Build Status](https://travis-ci.org/overtrue/wechat.svg?branch=master)](https://travis-ci.org/overtrue/wechat)
12+
[![Latest Stable Version](https://poser.pugx.org/overtrue/wechat/v/stable.svg)](https://packagist.org/packages/overtrue/wechat)
13+
[![Latest Unstable Version](https://poser.pugx.org/overtrue/wechat/v/unstable.svg)](https://packagist.org/packages/overtrue/wechat)
14+
[![Build Status](https://scrutinizer-ci.com/g/overtrue/wechat/badges/build.png?b=master)](https://scrutinizer-ci.com/g/overtrue/wechat/build-status/master)
15+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/overtrue/wechat/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/overtrue/wechat/?branch=master)
16+
[![Code Coverage](https://scrutinizer-ci.com/g/overtrue/wechat/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/overtrue/wechat/?branch=master)
17+
[![Total Downloads](https://poser.pugx.org/overtrue/wechat/downloads)](https://packagist.org/packages/overtrue/wechat)
18+
[![License](https://poser.pugx.org/overtrue/wechat/license)](https://packagist.org/packages/overtrue/wechat)
19+
20+
## 特点
21+
22+
- 命名不那么乱七八糟;
23+
- 隐藏开发者不需要关注的细节;
24+
- 方法使用更优雅,不必再去研究那些奇怪的的方法名或者类名是做啥用的;
25+
- 自定义缓存方式;
26+
- 符合 [PSR](https://github.com/php-fig/fig-standards) 标准,你可以各种方便的与你的框架集成;
27+
- 高度抽象的消息类,免去各种拼json与xml的痛苦;
28+
- 详细 Debug 日志,一切交互都一目了然;
29+
30+
## 安装
31+
32+
环境要求:PHP >= 5.5.9
33+
34+
1. 使用 [composer](https://getcomposer.org/)
35+
36+
```shell
37+
composer require "overtrue/wechat:~3.0" -vvv
38+
```
39+
40+
## 使用
41+
42+
基本使用(以服务端为例):
43+
44+
```php
45+
<?php
46+
47+
use EasyWeChat\Foundation\Application;
48+
49+
$options = [
50+
'debug' => true,
51+
'app_id' => 'wx3cf0f39249eb0e60',
52+
'secret' => 'f1c242f4f28f735d4687abb469072a29',
53+
'token' => 'easywechat',
54+
'log' => [
55+
'level' => 'debug',
56+
'file' => '/tmp/easywechat.log',
57+
],
58+
// ...
59+
];
60+
61+
$app = new Application($options);
62+
63+
$server = $app->server;
64+
$user = $app->user;
65+
66+
$server->setMessageHandler(function($message) use ($user) {
67+
$fromUser = $user->get($message->FromUserName);
68+
69+
return "{$fromUser->nickname} 您好!欢迎关注 overtrue!";
70+
});
71+
72+
$server->serve()->send();
73+
```
74+
75+
更多请参考[http://easywechat.org/](http://easywechat.org/)
76+
77+
## 文档
78+
79+
[http://easywechat.org/](http://easywechat.org/)
80+
81+
> 强烈建议看懂微信文档后再来使用本 SDK。
82+
83+
## 框架集成
84+
85+
[Laravel 5 拓展包: overtrue/laravel-wechat](https://github.com/overtrue/laravel-wechat)
86+
87+
## 贡献代码
88+
89+
[贡献指南](CONTRIBUTING.md)
90+
91+
## License
92+
93+
MIT

composer.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "overtrue/wechat",
3+
"description": "微信SDK",
4+
"keywords": [
5+
"wechat",
6+
"weixin",
7+
"weixin-sdk",
8+
"sdk"
9+
],
10+
"license": "MIT",
11+
"authors": [
12+
{
13+
"name": "overtrue",
14+
"email": "[email protected]"
15+
}
16+
],
17+
"require": {
18+
"php":">=5.5.0",
19+
"ext-openssl": "*",
20+
"pimple/pimple": "~3.0",
21+
"monolog/monolog": "^1.17",
22+
"overtrue/socialite": ">=1.0.7",
23+
"doctrine/cache": "~1.4",
24+
"guzzlehttp/guzzle": "~6.1",
25+
"symfony/http-foundation": "~2.6|~2.7|~2.8|~3.0",
26+
"symfony/psr-http-message-bridge": "0.2"
27+
},
28+
"require-dev": {
29+
"phpunit/phpunit": "~4.0",
30+
"mockery/mockery": "^1.0@dev"
31+
},
32+
"minimum-stability" : "dev",
33+
"autoload": {
34+
"psr-4": {
35+
"EasyWeChat\\": "src/"
36+
},
37+
"files": [
38+
"src/Payment/helpers.php"
39+
]
40+
}
41+
}

src/App/App.php

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace EasyWeChat\App;
4+
5+
use EasyWeChat\Core\AbstractAPI;
6+
7+
/**
8+
* Class App.
9+
*/
10+
class App extends AbstractAPI
11+
{
12+
const API_AUTHORIZATION = 'https://api.weixin.qq.com/sns/jscode2session';
13+
const API_QRCODE = 'https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode';
14+
private $appId;
15+
private $secret;
16+
private $payment = [];
17+
18+
19+
public function __construct($appId, $secret, $payment = [])
20+
{
21+
$this->appId = $appId;
22+
$this->secret = $secret;
23+
$this->payment = $payment;
24+
}
25+
26+
public function auth($code)
27+
{
28+
$params = [
29+
'appid' => $this->appId,
30+
'secret' => $this->secret,
31+
'grant_type' => 'authorization_code',
32+
'js_code' => $code,
33+
];
34+
35+
return $this->parseJson('get', [self::API_AUTHORIZATION, $params]);
36+
}
37+
38+
public function qrcode($path, $width = 430)
39+
{
40+
return $this->parseJSON('json', [self::API_QRCODE, compact('path', 'width')]);
41+
}
42+
43+
}

src/App/composer.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "easywechat/menu",
3+
"description": "menu module for EasyWeChat SDK.",
4+
"keywords": ["wechat", "weixin", "SDK", "menu", "easywechat"],
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "overtrue",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"autoload": {
13+
"psr-4": {
14+
"EasyWeChat\\App\\": "."
15+
}
16+
},
17+
"minimum-stability":"dev",
18+
"require-dev": {
19+
"phpunit/phpunit": "4.8.*",
20+
"mockery/mockery": "^1.0@dev"
21+
},
22+
"require": {
23+
"easywechat/core" : "dev-master"
24+
}
25+
}

0 commit comments

Comments
 (0)