matiit / wkop
Wykop API 客户端
0.2.0
2018-03-31 12:42 UTC
Requires
- guzzlehttp/guzzle: ~5.0
Requires (Dev)
- phing/phing: 2.*
- phpunit/phpunit: 4.3.*
- squizlabs/php_codesniffer: 1.5.0
This package is not auto-updated.
Last update: 2024-09-29 22:24:26 UTC
README
安装
您需要在您的应用 composer.json 文件的 require 部分添加此包
"matiit/wkop": "dev-master"
然后执行
composer update
用法
<?php use Wkop\Factory; $client = Factory::get('APP KEY', 'SECRET KEY'); $client->setUserCredentials('USER LOGIN', 'USER ACCOUNT KEY'); $client->logIn(); // Read resources // Resource name, method parameters, api parameters $results = $client->get('stream', ['index'], ['page' => 1]); // Post to resources // Resource name, method parameters, api parameters, post parameters $result = $client->post('entries', ['add'], [], ['body' => "test"]);
连接账户
<?php use Wkop\Factory; $url = Wkop\Helpers::Wkop\Helpers::getConnectUrl('REDIRECT URL', 'APP KEY', 'SECRET KEY'); $client = Factory::get('APP KEY', 'SECRET KEY'); /** * User should be redirected to that link. * He'll be asked to accept permissions and will be able to connect. * After clicking connect, he will be redirected back to your application to the REDIRECT URL * Handling Response is up to you. * Official Wykop documentation about response format: * http://www.wykop.pl/dla-programistow/dokumentacja/#info6_7_5 * * * In result you'll acquire two variables: * User login * User token (also called user key) */ // Here, get those variables. // And use them: $client->setUserCredentials('USER LOGIN', 'USER ACCOUNT KEY'); $client->logIn(); // From this moment, you will be able to make API calls as logged user.
想法
有改进的想法?请给我发邮件或发送 PullRequests。