deliciousdishes / vk-api-client
该软件包已被 弃用 且不再维护。没有建议替代软件包。
PHP 的 VK API 客户端
dev-master
2015-07-07 10:52 UTC
Requires
- php: >=5.3.3
This package is not auto-updated.
Last update: 2022-03-22 22:06:11 UTC
README
PHP 的 VKontakte API 客户端
##安装
如果您使用的是我们推荐的 Composer,请在您的 composer.json 文件中添加记录
{
"require":{
...
"deliciousdishes/vk-api-client": "dev-master"
...
},
"repositories":[
...
{
"type": "git",
"url": "https://github.com/mdimaas/vk-php-api-client"
}
...
]
}
##示例用法
获取 VK 授权的 URL
$helper = new \DeliciousDishes\VKLoginHelper("http://yoursite.com", "your_app_id", "your_app_secret", array("email", ...,"offline"));
$url = $helper->getLoginUrl();
点击链接后,VK 会重定向回页面,并在 GET 参数中包含安全代码。现在通过安全代码获取 VK 会话。示例
$helper = new \DeliciousDishes\VKLoginHelper("http://yoursite.com", "your_app_id", "your_app_secret", array("email", ...,"offline"));
$helper->getSession();
// or if your secure code saved in var
// $helper->getSession($secureCode);
会话存储当前用户 ID $session->getUserId()
以在 VK API 中发送请求。示例通过 IDs 获取用户信息
$request = new \DeliciousDishes\VKRequest($session, "users.get", array("user_ids" => $session->getUserId(),"fields" => "email,..."));
$response = $request->execute()->getResponseData();
查询结果:以 json 编码的值以适当的 PHP 类型混合。