socialconnect / github
与 GitHub 一起使用的出色 SDK
0.1.0
2015-08-23 11:09 UTC
Requires
- php: >=5.4
- ext-json: *
- socialconnect/common: ~0.5
Requires (Dev)
- phpunit/phpunit: ~4.5
- squizlabs/php_codesniffer: ~2.3.3
This package is auto-updated.
Last update: 2024-09-08 18:31:31 UTC
README
与 GitHub 一起使用的出色 SDK
可用方法
OAuth/WebHook
此库仅是客户端,请参阅
socialconnect/auth 项目中的 OAuth 提供程序。
ovr/github-webhook-service 项目中的 GitHub WebHook 服务。
安装
在您的 composer.json
中添加一个依赖项
{ "require": { "socialconnect/github": "~0.1" } }
运行 composer 安装程序
php composer.phar install
如何使用
首先,您需要创建服务
// Your GitHub Application's settings $appId = 'appId'; $appSecret = 'secret'; $ghClient = new \SocialConnect\GitHub\Client($appId, $appSecret); $ghClient->setHttpClient(new \SocialConnect\Common\Http\Client\Curl());
获取具有指定 $id 的用户
$ghClient = $ghClient->getUser('ovr'); var_dump($user);
自定义方法
$parameters = []; $result = $ghClient->request('method/CustomMethod', $parameters); if ($result) { var_dump($result); }
自定义实体
class MyUserEntitiy extends \SocialConnect\GitHub\Entity\User { public function myOwnMethod() { //do something } } $ghClient->getEntityUser(new MyUserEntitiy()); $user = $ghClient->getUser(1); if ($user) { $ghClient->myOwnMethod(); }
许可证
此项目是开源软件,许可协议为 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。