예제 #1
0
파일: Google.php 프로젝트: kris-nova/API
 public function get()
 {
     $callback = 'http://api.soundeavor.com/User/Auth/Login/Google/index.php';
     $config = new \Google_Config();
     $config->setApplicationName('Soundeavor');
     $config->setClientId(Config::getConfig('GoogleClientId'));
     $config->setClientSecret(Config::getConfig('GoogleClientSecret'));
     $config->setRedirectUri($callback);
     $client = new \Google_Client($config);
     /*
      * Add scopes (permissions) for the client https://developers.google.com/oauthplayground/
      */
     $client->addScope('https://www.googleapis.com/auth/plus.me');
     if (!isset($_GET['code'])) {
         $loginUrl = $client->createAuthUrl();
         header('Location: ' . $loginUrl);
     }
     $code = $_GET['code'];
     $client->authenticate($code);
     $accessToken = $client->getAccessToken();
     $accessToken = $accessToken['access_token'];
     $service = new \Google_Service_Plus($client);
     $scopes = $service->availableScopes;
     print_r($scopes);
     die;
 }
예제 #2
0
파일: Session.php 프로젝트: kris-nova/API
 /**
  * Defines the session write path
  *
  * @param string $writePath            
  */
 public function __construct($writePath = null)
 {
     if (empty($writePath)) {
         $writePath = Config::getConfig('SessionSavePath');
     }
     if (!file_exists(dirname($writePath))) {
         mkdir(dirname($writePath), null, true);
     }
     session_save_path($writePath);
 }
예제 #3
0
 /**
  * Will init and build the transaction
  *
  * @param Request $request            
  */
 public function __construct(Request $request)
 {
     $this->request = $request;
     $this->startTime = microtime(1);
     $this->id = $request->id;
     $this->date = date('mdy');
     $this->transactionDirectory = Config::getConfig('TransactionDirectory') . '/' . $this->date;
     if (!file_exists($this->transactionDirectory)) {
         mkdir($this->transactionDirectory, 0744, 1);
     }
     $bytesWritten = $this->build();
 }
예제 #4
0
파일: Facebook.php 프로젝트: kris-nova/API
 public function get()
 {
     $fb = new Fb(['app_id' => Config::getConfig('FacebookAppId'), 'app_secret' => Config::getConfig('FacebookSecret'), 'default_graph_version' => Config::getConfig('FacebookAPIVersion')]);
     $fields = $this->request->get('facebookFields_text', false, '');
     $edge = $this->request->get('facebookEdge_text', false, '');
     $response = $fb->sendRequest('GET', '/' . $this->request->get('facebookUserId_text') . $edge, array('fields' => $fields), $this->request->get('facebookAccessToken_text'));
     $facebookBody = $response->getDecodedBody();
     $body = $this->request->body;
     $body['facebookResponse_text'] = $facebookBody;
     $this->request->response->body = $body;
     $this->request->response->code = r_success;
 }
예제 #5
0
파일: Spotify.php 프로젝트: kris-nova/API
 /**
  * (non-PHPdoc)
  * @see \API\src\Endpoints\Endpoints::get()
  */
 public function get()
 {
     $session = new Session(Config::getConfig('SpotifyAppId'), Config::getConfig('SpotifySecret'));
     $callback = 'http://api.soundeavor.com/User/Auth/Login/Spotify/index.php';
     $session->setRedirectUri($callback);
     $url = $session->getAuthorizeUrl();
     if (!isset($_GET['code'])) {
         header('Location: ' . $url);
     }
     $code = $_GET['code'];
     $api = new SpotifyWebAPI();
     $session->requestToken($code);
     $api->setAccessToken($session->getAccessToken());
     $me = $api->me();
     $body['spotifyName_text'] = $me->display_name;
     $body['spotifyAccessToken_text'] = $session->getAccessToken();
     $body['spotifyUserId_text'] = $me->id;
     $this->request->response->body = $body;
     $this->request->response->code = r_success;
 }
예제 #6
0
 /**
  * Send an empty request here
  *
  * The API will forward the request to the SoundCloud API, prompt the user to login
  * Return the token and login URL to the consumer for reference
  * We are now logged in with SoundCloud, and can start scraping user data
  */
 public function get()
 {
     $callback = 'http://' . Config::getConfig('Hostname') . '/User/Auth/Login/SoundCloud/index.php';
     $facade = new SoundcloudFacade(Config::getConfig('SoundCloudAppId'), Config::getConfig('SoundCloudSecret'), $callback);
     $url = $facade->getAuthUrl();
     if (isset($_GET['code'])) {
         $code = $_GET['code'];
         $token = $facade->codeForToken($code);
         $rBody = $token->bodyArray();
         $accessToken = $rBody['access_token'];
         $me = $facade->get('/me')->request();
         $scBody = $me->bodyArray();
         $clientId = $scBody['id'];
         $body['soundcloudAccessToken_text'] = $accessToken;
         $body['soundcloudUserId_text'] = $clientId;
         $body['soundcloudName_text'] = $scBody['full_name'];
         $this->request->response->body = $body;
         $this->request->response->code = r_success;
         return $this->request;
     } else {
         header('Location: ' . $url);
     }
 }
예제 #7
0
파일: Autoload.php 프로젝트: kris-nova/API
 /**
  * All PHP settings are interpretted here
  */
 protected function phpSettings()
 {
     date_default_timezone_set('GMT');
     if (Config::getConfig('debug') == 1) {
         error_reporting(-1);
     } else {
         ini_set("log_errors", Config::getConfig('LogErrors'));
         ini_set("error_log", Config::getConfig('LoggerDirectory') . '/' . Config::getConfig('ErrorLogFile') . date('Y-m-d'));
     }
 }
예제 #8
0
파일: Endpoints.php 프로젝트: kris-nova/API
 /**
  */
 protected function createTable()
 {
     $endpoint = $this->request->endpoint;
     $keyspace = $this->request->keyspace;
     $this->cassandra->createKeyspace($keyspace);
     $createTableQuery = $this->getCreateTableQuery();
     $this->cassandra = new Connector(Config::getConfig('CassandraNodeString'), (int) Config::getConfig('CassandraPort'));
     $this->cassandra->connect($keyspace);
     Logger::debug('Create Table Query : ' . $createTableQuery);
     $this->cassandra->query($createTableQuery);
 }
예제 #9
0
파일: GET.php 프로젝트: kris-nova/API
use API\src\Config\Config;
use Httpful\Request;
require_once __DIR__ . '/../../../../../Autoload.php';
/******************************************************************************
 * User/Auth/Login/SoundCloud
 * 
 * Used to authenticate a user via SoundCloud
 * 
 * GET() Example
 * 
 *****************************************************************************/
/******************************************************************************
 * Define URI parameters
 *****************************************************************************/
$protocol = 'http://';
$hostname = Config::getConfig('Hostname');
$endpoint = '/User/Auth/Login/SoundCloud/';
/******************************************************************************
 * Define body ARRAY() and build parameters
*****************************************************************************/
$body[''] = '';
$body[''] = '';
$paramString = '?';
foreach ($body as $key => $value) {
    if (empty($key) || empty($value)) {
        continue;
    }
    $paramString .= $key . '=' . $value . '&';
}
$paramString = substr($paramString, 0, -1);
/******************************************************************************
예제 #10
0
파일: Logger.php 프로젝트: kris-nova/API
 /**
  * Will append the line to the configured logfile
  *
  * @param unknown $line            
  * @return number
  */
 protected static function write($line, $level)
 {
     if (static::$logLevel == -1 || static::$logLevel & $level) {
         $date = date('Y-m-d');
         $logfile = Config::getConfig('LoggerDirectory') . '/' . Config::getConfig('LoggerFile') . $date;
         if (!file_exists(dirname($logfile))) {
             mkdir(dirname($logfile), '0775', true);
         }
         return file_put_contents($logfile, $line, FILE_APPEND);
     }
     return false;
 }
예제 #11
0
파일: Facebook.php 프로젝트: kris-nova/API
<?php

use Facebook\Facebook;
use API\src\Config\Config;
use API\src\Server\Session;
require_once __DIR__ . '/../Autoload.php';
$fb = new Facebook(['app_id' => Config::getConfig('FacebookAppId'), 'app_secret' => Config::getConfig('FacebookSecret'), 'default_graph_version' => Config::getConfig('FacebookAPIVersion')]);
$app = $fb->getApp();
$accessToken = $app->getAccessToken();
$accessTokenValue = $accessToken->getValue();
$oauth2 = $fb->getOAuth2Client();
$tokenMeta = $oauth2->debugToken($accessToken);
$tokenMeta->validateAppId(Config::getConfig('FacebookAppId'));
$tokenMeta->validateExpiration();