本文整理汇总了PHP中Client::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::get方法的具体用法?PHP Client::get怎么用?PHP Client::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client
的用法示例。
在下文中一共展示了Client::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doGet
/**
* @param string $url relative URL
* @return \GuzzleHttp\Message\FutureResponse|\GuzzleHttp\Message\ResponseInterface|\GuzzleHttp\Ring\Future\FutureInterface|null
* @throws \Exception
* @throws \GuzzleHttp\Exception\ClientException
* @throws \InvalidArgumentException
*/
protected function doGet($url)
{
if (!$url) {
throw new \InvalidArgumentException('URL erforderlich!');
}
try {
return $this->client->get($url);
} catch (ClientException $e) {
if ($e->getCode() == 404) {
return null;
}
throw $e;
}
}
示例2: lxserver_main
function lxserver_main()
{
global $gbl, $sgbl, $login, $ghtml;
global $argv, $argc;
if ($argv[1] === 'slave') {
$login = new Client(null, null, 'slave');
$gbl->is_slave = true;
$gbl->is_master = false;
$rmt = unserialize(lfile_get_contents("__path_slave_db"));
$login->password = $rmt->password;
$argv[1] = "Running as Slave";
} else {
if ($argv[1] === 'master') {
$login = new Client(null, null, 'admin');
$gbl->is_master = true;
$gbl->is_slave = false;
$login->get();
$argv[1] = "Running as Master";
} else {
print "Wrong arguments\n";
exit;
}
}
$login->cttype = 'admin';
// Set php script execution timer to unlimited
set_time_limit(0);
// Start internal socket for remote
some_server();
}
示例3: find
/**
* Retrieve an array of Publication objects according to a search query.
*
* @param array $query The query.
* @return Publication[]
*/
public static function find(array $query)
{
$pubs = Client::get('publication', $query);
return array_map(function ($data) {
return new self($data);
}, $pubs);
}
示例4: getWeatherFor
public function getWeatherFor($city)
{
$client = new Client(['base_uri' => 'http://api.openweathermap.org/data/2.5/', 'timeout' => 2.0]);
$response = $client->get('weather?q=' . $city);
$contents = $response->getBody()->getContents();
return json_decode($contents);
}
示例5: getMimetype
/**
* Get the mimetype of a file.
*
* @param string $path
*
* @return array|false
*/
public function getMimetype($path)
{
$stream = tmpfile();
fwrite($stream, $this->client->get($path));
rewind($stream);
return ['mimetype' => Util::guessMimeType(stream_get_meta_data($stream)['uri'], stream_get_contents($stream))];
}
示例6: get
/**
* @param $url
* @return Response
*/
public function get($url)
{
$bits = explode('v=', $url);
$videoId = end($bits);
/** @var ResolveResponse $response */
return parent::get(sprintf(self::API_URL, $this->apiKey, $videoId));
}
示例7: getLastPage
/**
* @return Response|null
*/
public function getLastPage()
{
if ($this->pages['last']) {
return $this->client->get(str_replace(Request::API_URL, '', $this->pages['last']));
}
return NULL;
}
示例8: create
public function create($pid, $name, $identifier = null, $template = null)
{
if (!$identifier) {
$identifier = Identifiers::getIdentifier($name);
if (!$identifier) {
throw new Exception("Identifier derived from dimension name '{$name}' is not valid. " . "Choose other name or custom identifier.");
}
}
$call = $this->client->get("/gdc/md/{$pid}/data/sets");
$existingDataSets = [];
foreach ($call['dataSetsInfo']['sets'] as $r) {
$existingDataSets[] = $r['meta']['identifier'];
}
if (!in_array(Identifiers::getDateDimensionId($name, $template), $existingDataSets)) {
$this->client->getDatasets()->executeMaql($pid, sprintf('INCLUDE TEMPLATE "%s" MODIFY (IDENTIFIER "%s", TITLE "%s");', self::getTemplateUrn($template), $identifier, $name));
}
}
示例9: read
/**
*
* @param string $session_id
* @return string
*/
public function read($session_id)
{
if (isset($this->_cache[$session_id])) {
return $this->_cache[$session_id];
}
$session_data = $this->_client->get($this->_prefix . $session_id)->data;
return $this->_cache[$session_id] = $session_data === null ? '' : $session_data;
}
示例10: create
public function create($pid, $name, $identifier = null)
{
if (!$identifier) {
$identifier = Identifiers::getIdentifier($name);
if (!$identifier) {
throw new Exception("Identifier derived from dimension name '{$name}' is not valid. " . "Choose other name or custom identifier.");
}
}
$call = $this->gdClient->get("/gdc/md/{$pid}/data/sets");
$existingDataSets = [];
foreach ($call['dataSetsInfo']['sets'] as $r) {
$existingDataSets[] = $r['meta']['identifier'];
}
if (!in_array(self::getTimeDimensionIdentifier($name), $existingDataSets)) {
$this->gdClient->getDatasets()->executeMaql($pid, self::getCreateMaql($identifier, $name));
}
}
示例11: getSignedJSON
/**
* Perform a GET request, get a decoded JSON response.
* Internally verifies an Ed25519 signature.
*
* @param string $url
* @param SignaturePublicKey $publicKey
* @param array $params
* @return mixed
*/
public function getSignedJSON(string $url, SignaturePublicKey $publicKey, array $params = [])
{
$response = $this->client->get($url, $this->params($params, $url));
if ($response instanceof Response) {
return $this->parseSignedJSON($response, $publicKey);
}
return null;
}
示例12: diff
public function diff($pid, $model)
{
$uri = "/gdc/projects/{$pid}/model/diff?includeDeprecated=true&includeGrain=true";
$result = $this->client->post($uri, ['diffRequest' => ['targetModel' => $model]]);
if (isset($result['asyncTask']['link']['poll'])) {
$try = 1;
do {
sleep(10 * $try);
$taskResponse = $this->client->get($result['asyncTask']['link']['poll']);
if (!isset($taskResponse['asyncTask']['link']['poll'])) {
if (isset($taskResponse['projectModelDiff']['updateScripts'])) {
$lessDestructive = [];
$moreDestructive = [];
// Preserve data if possible
foreach ($taskResponse['projectModelDiff']['updateScripts'] as $updateScript) {
if ($updateScript['updateScript']['preserveData'] && !$updateScript['updateScript']['cascadeDrops']) {
$lessDestructive = $updateScript['updateScript']['maqlDdlChunks'];
}
if (!count($lessDestructive) && !$updateScript['updateScript']['preserveData'] && !$updateScript['updateScript']['cascadeDrops']) {
$lessDestructive = $updateScript['updateScript']['maqlDdlChunks'];
}
if (!$updateScript['updateScript']['preserveData'] && $updateScript['updateScript']['cascadeDrops']) {
$moreDestructive = $updateScript['updateScript']['maqlDdlChunks'];
}
if (!count($moreDestructive) && $updateScript['updateScript']['preserveData'] && $updateScript['updateScript']['cascadeDrops']) {
$moreDestructive = $updateScript['updateScript']['maqlDdlChunks'];
}
}
$description = [];
foreach ($taskResponse['projectModelDiff']['updateOperations'] as $o) {
$description[] = vsprintf($o['updateOperation']['description'], $o['updateOperation']['parameters']);
}
return ['moreDestructiveMaql' => $moreDestructive, 'lessDestructiveMaql' => $lessDestructive, 'description' => $description];
} else {
throw Exception::unexpectedResponseError('Polling of Model diff could not be finished', 'GET', $result['asyncTask']['link']['poll'], $taskResponse);
}
}
$try++;
} while (true);
} else {
throw Exception::unexpectedResponseError('Polling of Model diff could not be started', 'POST', $uri, $result);
}
return false;
}
示例13: find
/**
* Retrieve an array of CourseSegmentInstance objects according to
* a search query.
*
* @param array $query The query.
* @return CourseSegmentInstance[]
*/
public static function find(array $query)
{
if (isset($query['semester']) && $query['semester'] instanceof Semester) {
$query['semester'] = $query['semester']->daisyFormat();
}
$csis = Client::get("courseSegment", $query);
return array_map(function ($data) {
return new self($data);
}, $csis);
}
示例14: test_set_get
public function test_set_get()
{
$client = new Client();
$client->addServers(array('127.0.0.1', 11211), array('127.0.0.1', 11212));
$this->assertFalse($client->isConnected());
$this->assertInstanceOf('\\Memcached', $client->getMemcached());
$this->assertTrue($client->isConnected());
$this->assertEquals(1, $client->set('foobar', 42));
$this->assertEquals(42, $client->get('foobar'));
}
示例15: up
/**
* Convert foreign id values from string to MongoId.
*
* @return void
*/
public function up()
{
$db = \DB::getMongoDB();
Client::get()->each(function (Client $client) use($db) {
// The Client model has a mutator that converts lrs_id values to MongoId objects.
$client->lrs_id = $client->lrs_id;
$client->save();
});
echo 'Foreign id values in client collection converted from string to MongoId.' . PHP_EOL;
}