本文整理汇总了PHP中getClient函数的典型用法代码示例。如果您正苦于以下问题:PHP getClient函数的具体用法?PHP getClient怎么用?PHP getClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getClient函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAnalytics
function getAnalytics()
{
$client = getClient();
$token = Authenticate($client);
$analytics = new Google_Service_Analytics($client);
return $analytics;
}
示例2: setUp
/**
* @throws ClientException
*/
public function setUp()
{
$connector = new Connector($this->client);
$this->client = getClient($connector);
$collectionName = 'ArangoDB-PHP-Core-CollectionTestSuite-Collection';
$collectionOptions = ['waitForSync' => true];
$collectionParameters = [];
$options = $collectionOptions;
$this->client->bind('Request', function () {
$request = $this->client->getRequest();
return $request;
});
$request = $this->client->make('Request');
$request->options = $options;
$request->body = ['name' => $collectionName];
$request->body = self::array_merge_recursive_distinct($request->body, $collectionParameters);
$request->body = json_encode($request->body);
$request->path = $this->client->fullDatabasePath . self::API_COLLECTION;
$request->method = self::METHOD_POST;
$responseObject = $request->send();
$body = $responseObject->body;
$this->assertArrayHasKey('code', json_decode($body, true));
$decodedJsonBody = json_decode($body, true);
$this->assertEquals(200, $decodedJsonBody['code']);
$this->assertEquals($collectionName, $decodedJsonBody['name']);
}
示例3: getAccessToken
function getAccessToken(&$fb, $bucket, $tokenFile)
{
// Read file from Google Storage
$client = getClient();
$storage = getStorageService($client);
$tokensStr = getTokens($client, $storage, $bucket, $tokenFile);
if (empty($tokensStr)) {
quit("No more FB access tokens in storage -- login to app ASAP to generate a token");
} else {
$tokens = json_decode($tokensStr, true);
// 'true' will turn this into associative array instead of object
// Validate the token before use. User may have logged off facebook, or deauthorized this app.
// shuffle the array to get random order of iteration
shuffle($tokens);
//var_dump($tokens);
foreach ($tokens as $token) {
$response = $fb->get('/me', $token);
if (!$response->isError()) {
// access_token is valid token
return $token;
}
}
quit("None of the tokens are valid");
}
}
示例4: setUp
/**
*
*/
public function setUp()
{
$connector = new Connector();
$this->client = $this->client = getClient($connector);
$this->collectionNames[0] = 'ArangoDB-PHP-Core-CollectionTestSuite-Collection-01';
$this->collectionNames[1] = 'ArangoDB-PHP-Core-CollectionTestSuite-Collection-02';
$this->collectionNames[2] = 'ArangoDB-PHP-Core-CollectionTestSuite-Collection-03';
}
示例5: setUp
/**
*
*/
public function setUp()
{
$connector = new Connector();
$this->connector = $connector;
$this->client = $this->client = getClient($connector);
$this->client->bind('Request', function () {
$request = $this->client->getRequest();
return $request;
});
}
示例6: IsSubscribed
public static function IsSubscribed($clientId = NULL)
{
if (is_null($clientId)) {
if (!isset($_GET["clientid"])) {
return NULL;
} else {
$CurrentClientId = $_GET["clientid"];
return self::IsSubscribed($CurrentClientId);
}
}
return getClient($clientId)->IsSubscribed;
}
示例7: __construct
function __construct($appid, $appsecret, $mime_type, $folder_id)
{
$curl_options = array(CURLOPT_SSL_VERIFYPEER => FALSE, CURLOPT_SSL_VERIFYHOST => FALSE, CURLOPT_FORBID_REUSE => TRUE, CURLOPT_SSLVERSION => 1, CURLOPT_FORBID_REUSE => TRUE, CURLOPT_RETURNTRANSFER => TRUE);
$this->parallel_curl = new ParallelCurl(100, $curl_options);
$this->appid = $appid;
$this->appsecret = $appsecret;
$this->mime_type = $mime_type;
$this->folder_id = $folder_id;
$this->cache = new Cache();
$this->cache->setCache('cache');
$this->get_token_from_wechat();
if (file_exists(__DIR__ . "/csv/") == false) {
mkdir(__DIR__ . "/csv/");
}
$this->client = getClient();
$this->service = new Google_Service_Drive($this->client);
}
示例8: fetchPages
/**
* Fetch and process a paged response from JoindIn.
*
* @param $initial
* The initial URL to fetch. That URL may result in others getting
* fetched as well.
* @param callable $processor
* A callable that will be used to process each page of results. Its signature
* must be: (\SplQueue $pages, ResponseInterface $response, $index)
* @param int $concurrency
* The number of concurrent requests to send. In practice this kinda has to
* be 1, or else Guzzle will conclude itself before getting to later-added
* entries.
*/
function fetchPages($initial, callable $processor, $concurrency = 1)
{
$client = getClient();
$pages = new \SplQueue();
$pages->enqueue($initial);
$pageProcessor = partial($processor, $pages);
$pageRequestGenerator = function (\SplQueue $pages) {
foreach ($pages as $page) {
(yield new Request('GET', $page));
}
};
$pool = new Pool($client, $pageRequestGenerator($pages), ['concurrency' => $concurrency, 'fulfilled' => $pageProcessor]);
// Initiate the transfers and create a promise
$promise = $pool->promise();
// Force the pool of requests to complete.
$promise->wait();
}
示例9: getClientForToken
function getClientForToken ($access_token, $fake_it = false) {
$client = getClient();
$accessToken = false;
// Since w're passed the access_token part only,
// we will fake the token.
// We don't know when it was created or when it expires,
// so we fake it.
$tmpl = '{
"access_token":"%s",
"token_type":"Bearer",
"expires_in":"3600",
"id_token":"",
"created":%s}';
$token_file = PATH.'/tokens/'.$access_token;
if (!file_exists($token_file)) {
if ($fake_it) {
$accessToken = sprintf($tmpl, $access_token, time());
}
} else {
$accessToken = file_get_contents(PATH.'/tokens/'.$access_token);
}
if (empty($accessToken)) {
$client = null;
} else {
$client->setAccessToken($accessToken);
// Refresh the token if it's expired.
if ($client->isAccessTokenExpired()) {
$refreshToken = $client->getRefreshToken();
if (!empty($refreshToken)) {
$client->refreshToken($refreshToken);
//We'd want to return this.
$accessToken = $client->getAccessToken();
file_put_contents(PATH.'/tokens/'.$access_token);
}
}
}
return $client;
}
示例10: setUp
/**
*
*/
public function setUp()
{
$connector = new Connector();
$this->client = getClient($connector);
}
示例11: print_usage
}
if (!isset($arguments['partner_id']) || !$arguments['partner_id'] || is_null($arguments['partner_id'])) {
print_usage('missing argument --partner_id');
}
if (!isset($arguments['admin_secret']) || !$arguments['admin_secret'] || is_null($arguments['admin_secret'])) {
print_usage('missing argument --admin_secret');
}
if (!isset($arguments['host']) || !$arguments['host'] || is_null($arguments['host'])) {
print_usage('missing argument --host');
}
if (!file_exists($arguments['ini'])) {
print_usage('config file not found ' . $arguments['ini']);
}
error_reporting(0);
$confObj = init($arguments['ini'], $arguments['infra']);
$kclient = getClient($arguments['partner_id'], $arguments['admin_secret'], $arguments['host']);
$baseTag = $confObj->general->component->name;
$defaultTags = "autodeploy, {$baseTag}_{$confObj->general->component->version}";
$sections = explode(',', $confObj->general->component->required_widgets);
if ($includeCode) {
$code[] = '$c = new Criteria();';
$code[] = '$c->addAnd(UiConfPeer::PARTNER_ID, ' . $confObj->statics->partner_id . ');';
$code[] = '$c->addAnd(UiConfPeer::TAGS, "%' . $baseTag . '_".$this->kmc_' . $baseTag . '_version."%", Criteria::LIKE);';
$code[] = '$c->addAnd(UiConfPeer::TAGS, "%autodeploy%", Criteria::LIKE);';
$code[] = '$this->confs = UiConfPeer::doSelect($c);';
}
$tags_search = array();
foreach ($sections as $section) {
$sectionName = trim($section);
$sectionBase = $sectionName . 's';
$baseSwfUrl = $confObj->{$sectionName}->{$sectionBase}->swfpath;
示例12: testPre
/**
* When a test case contains adds/modifies/deletes being sent to the server,
* these changes must be extracted from the test data and manually performed
* using the api to achieve the desired behaviour by the server
*
* @throws Horde_Exception
*/
function testPre($name, $number)
{
global $debuglevel;
$ref0 = getClient($name, $number);
// Extract database (in horde: service).
if (preg_match('|<Alert>.*?<Target>\\s*<LocURI>([^>]*)</LocURI>.*?</Alert>|si', $ref0, $m)) {
$GLOBALS['service'] = $m[1];
}
if (!preg_match('|<SyncHdr>.*?<Source>\\s*<LocURI>(.*?)</LocURI>.*?</SyncHdr>|si', $ref0, $m)) {
echo $ref0;
throw new Horde_Exception('Unable to find device id');
}
$device_id = $m[1];
// Start backend session if not already done.
if ($GLOBALS['testbackend']->getSyncDeviceID() != $device_id) {
$GLOBALS['testbackend']->sessionStart($device_id, null, Horde_SyncMl_Backend::MODE_TEST);
}
// This makes a login even when a logout has occured when the session got
// deleted.
$GLOBALS['testbackend']->setUser(SYNCMLTEST_USERNAME);
$ref1 = getServer($name, $number + 1);
if (!$ref1) {
return;
}
$ref1 = str_replace(array('<![CDATA[', ']]>', '<?xml version="1.0"?><!DOCTYPE SyncML PUBLIC "-//SYNCML//DTD SyncML 1.1//EN" "http://www.syncml.org/docs/syncml_represent_v11_20020213.dtd">'), '', $ref1);
// Check for Adds.
if (preg_match_all('|<Add>.*?<type[^>]*>(.*?)</type>.*?<LocURI[^>]*>(.*?)</LocURI>.*?<data[^>]*>(.*?)</data>.*?</Add|si', $ref1, $m, PREG_SET_ORDER)) {
foreach ($m as $c) {
list(, $contentType, $locuri, $data) = $c;
// Some Sync4j tweaking.
switch (Horde_String::lower($contentType)) {
case 'text/x-s4j-sifn':
$data = Horde_SyncMl_Device_sync4j::sif2vnote(base64_decode($data));
$contentType = 'text/x-vnote';
$service = 'notes';
break;
case 'text/x-s4j-sifc':
$data = Horde_SyncMl_Device_sync4j::sif2vcard(base64_decode($data));
$contentType = 'text/x-vcard';
$service = 'contacts';
break;
case 'text/x-s4j-sife':
$data = Horde_SyncMl_Device_sync4j::sif2vevent(base64_decode($data));
$contentType = 'text/calendar';
$service = 'calendar';
break;
case 'text/x-s4j-sift':
$data = Horde_SyncMl_Device_sync4j::sif2vtodo(base64_decode($data));
$contentType = 'text/calendar';
$service = 'tasks';
break;
case 'text/x-vcalendar':
case 'text/calendar':
if (preg_match('/(\\r\\n|\\r|\\n)BEGIN:\\s*VTODO/', $data)) {
$service = 'tasks';
} else {
$service = 'calendar';
}
break;
default:
throw new Horde_Exception("Unable to find service for contentType={$contentType}");
}
$result = $GLOBALS['testbackend']->addEntry($service, $data, $contentType);
if (is_a($result, 'PEAR_Error')) {
echo "error importing data into {$service}:\n{$data}\n";
throw new Horde_Exception_Wrapped($result);
}
if ($debuglevel >= 2) {
echo "simulated {$service} add of {$result} as {$locuri}!\n";
echo ' at ' . date('Y-m-d H:i:s') . "\n";
if ($debuglevel >= 10) {
echo "data: {$data}\nsuid={$result}\n";
}
}
// Store UID used by server.
$GLOBALS['mapping_locuri2uid'][$locuri] = $result;
}
}
// Check for Replaces.
if (preg_match_all('|<Replace>.*?<type[^>]*>(.*?)</type>.*?<LocURI[^>]*>(.*?)</LocURI>.*?<data[^>]*>(.*?)</data>.*?</Replace|si', $ref1, $m, PREG_SET_ORDER)) {
foreach ($m as $c) {
list(, $contentType, $locuri, $data) = $c;
// Some Sync4j tweaking.
switch (Horde_String::lower($contentType)) {
case 'sif/note':
case 'text/x-s4j-sifn':
$data = Horde_SyncMl_Device_sync4j::sif2vnote(base64_decode($data));
$contentType = 'text/x-vnote';
$service = 'notes';
break;
case 'sif/contact':
case 'text/x-s4j-sifc':
$data = Horde_SyncMl_Device_sync4j::sif2vcard(base64_decode($data));
//.........这里部分代码省略.........
示例13: setUp
/**
*
*/
public function setUp()
{
$this->connector = $this->getMockBuilder('TestConnector')->getMock();
$this->client = getClient($this->connector);
}
示例14: checkSession
include_once "mod.order.php";
include_once "mod.optional.php";
include_once "ctrl.order.php";
include_once "ctrl.client.php";
include_once "ctrl.login.php";
// check user authentication
checkSession($_SESSION['sess_user_id']);
if (isset($_GET['ordid'])) {
$oid = $_GET['ordid'];
$orddetail = getOrderById($oid, $db);
$rf = getRf($db);
$odrf = getRfById($oid, $db);
$os = getOS($db);
$app = getApp($db);
$odapp = getAppById($oid, $db);
$cli = getClient($db);
$sta = getStatus($db);
} else {
header("location: " . ROOT . "order_list.php");
exit;
}
?>
<html lang="en-US">
<head>
<meta charset="utf-8">
<link href="<?php
echo CSS;
?>
import.css" type="text/css" rel="stylesheet"/>
<script src="<?php
echo JS;
示例15: getClient
<?php
include_once "session.php";
$search = $_POST['searchFor'];
$where = $_POST['where'];
if ($where == "Clients") {
if (strlen($search) == 0) {
getClient(0, "all");
} else {
searchClient($search);
}
} elseif ($where == "Drivers") {
if (strlen($search) == 0) {
getDrivers(0, "all");
} else {
searchDriver($search);
}
} elseif ($where == "Deliveries") {
if (strlen($search) == 0) {
//Get all data here
} else {
//Get specific data here.
}
} elseif ($where == "Reports") {
if (strlen($search) == 0) {
getEmergencyTable(0, "all");
} else {
searchEmergencies($search);
}
} elseif ($where == "Accounts") {
if (strlen($search) == 0) {