dindigital / social-auth
此包最新版本(dev-master)没有提供许可信息。
dev-master
2014-12-24 13:44 UTC
Requires
- google/apiclient: dev-master
This package is not auto-updated.
Last update: 2024-09-24 08:24:10 UTC
README
安装
使用composer
{
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"dindigital/social_auth": "dev-master"
}
}
认证示例
require 'vendor/autoload.php'; use Din\SocialAuth\Google\Auth; use Din\SocialAuth\Google\Scope; use Din\SocialAuth\Google\Exception\Auth_Exception; /** * Configurações */ $id = ''; $secret = ''; $devkey = ''; $token = null; $redirect_url = ''; /** * Modelo Implementação */ $googleAuth = new Auth; $googleAuth->setClientId($id); $googleAuth->setClientSecret($secret); $googleAuth->setDeveloperKey($devkey); $googleAuth->setRedirectUri($redirect_url); // Define qual permissão o Google fornecerá $scope = new Scope; $scope->setYouTube(); $scope->setAnalytcs(); $googleAuth->setScope($scope); try { if (isset($_GET['code'])) { $googleAuth->authCode($_GET['code']); // Persistir o token: $googleAuth->getToken() header("Location: {$redirect_url}"); } $googleAuth->setToken($token); } catch (Exception $e) { $url = $googleAuth->getAuthUrl(); echo '<h1>'.$e->getMessage().'</h1>'; echo '<a href="'.$url.'">Login</a>'; exit; } if ($googleAuth->hasUpdated()) { // Persistir o token: $googleAuth->getToken() }
YouTube
插入视频
$youtube = new Din\SocialAuth\Google\Services\YouTube($googleAuth); $youtube->setTitle('Teste YouTube'); $youtube->setDescription('Teste da descrução'); $youtube->setTags(array('tag1', 'tag2')); $youtube->setPrivacy('private'); $file = $_SERVER['DOCUMENT_ROOT'] . '/test.mp4'; $id_youtube = $youtube->insert($file); echo $id_youtube;
删除视频
分析
按日期范围搜索URL查看
$ga = new Din\SocialAuth\Google\Services\Analytics($googleAuth); $ga->setProperty('XXXXXXX'); $ga->setStartDate('2014-12-01'); $ga->setEndDate(date('Y-m-d')); $ga->setUri('/xxxxx/xxxxxxxxx/'); echo $ga->getVisits();