本文整理汇总了PHP中Client类的典型用法代码示例。如果您正苦于以下问题:PHP Client类的具体用法?PHP Client怎么用?PHP Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreatePushURI
public function testCreatePushURI()
{
$client = new Client('', true);
$pushUri = $client->getPushURI((new Message())->setDeviceIdentifier('foobar'));
$this->assertContains('develop', $pushUri);
$this->assertContains('foobar', $pushUri);
}
示例2: testClose
public function testClose()
{
$c = new Client();
$c->connect();
$this->assertInstanceOf("Bunny\\Protocol\\MethodChannelCloseOkFrame", $c->channel()->close());
$c->disconnect();
}
示例3: 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();
}
示例4: actionCompleteRegistrationAjax
public function actionCompleteRegistrationAjax()
{
$client = new Client();
$client->attributes = $_POST['Client'];
if ($client->save()) {
$drive = new Drive();
$drive->attributes = $_POST['Drive'];
$drive->client_id = $client->primaryKey;
$drive->creation_date = date("Y-m-d H:i:s");
if ($drive->save()) {
$driv = Drive::model()->findByPk($drive->primaryKey);
$message = new YiiMailMessage();
$message->view = 'pruebamanejo';
$message->setBody(array("client" => $client, "drive" => $driv), 'text/html');
$message->setSubject('Solicitud Prueba de Manejo');
foreach ($driv->concessioner->emails as $email) {
// if($email->type=="DRIVE"){
if ($email->type == "QUOTATION") {
$message->addTo($email->description);
}
}
// $message->addTo("anaquishpe@ayasa.com.ec");
// $message->addTo("mgonzalez@ayasa.com.ec");
$message->addTo("gzumarraga@ayasa.com.ec");
$message->addTo("solicitudeswebnissan@gmail.com");
$message->setFrom(array(Yii::app()->params['adminEmail'] => 'El Equipo Nissan Ecuador'));
Yii::app()->mail->send($message);
echo json_encode(true);
} else {
echo json_encode(false);
}
}
}
示例5: send
public function send($to, $txt)
{
$client = new Client($this->user, $this->token);
$data = array("destinations" => $to, "text" => $txt);
$response = $client->post('messages', $data);
return $response->deliveryToken;
}
示例6: trim
/**
* 创建client实例
*/
function &getSingleClient($smownerid)
{
global $current_user;
static $client = false;
if ($client === false) {
global $adb;
$gwUrl = 'http://sdkhttp.eucp.b2m.cn/sdk/SDKService';
$sql = "select * from ec_messageaccount where smownerid='" . $smownerid . "'";
$result = $adb->query($sql);
$serialNumber = trim($adb->query_result($result, 0, 'username'));
$password = trim($adb->query_result($result, 0, 'password'));
//$password='12345';
$sessionKey = $password;
$connectTimeOut = 5;
/**
* 远程信息读取超时时间,单位为秒
*/
$readTimeOut = 10;
/**
$proxyhost 可选,代理服务器地址,默认为 false ,则不使用代理服务器
$proxyport 可选,代理服务器端口,默认为 false
$proxyusername 可选,代理服务器用户名,默认为 false
$proxypassword 可选,代理服务器密码,默认为 false
*/
$proxyhost = false;
$proxyport = false;
$proxyusername = false;
$proxypassword = false;
$client = new Client($gwUrl, $serialNumber, $password, $sessionKey, $proxyhost, $proxyport, $proxyusername, $proxypassword, $connectTimeOut, $readTimeOut);
$client->setOutgoingEncoding("UTF-8");
}
return $client;
}
示例7: view
/**
* The catalog view handler.
*
* @param int $id The Product id.
* @return string The HTML code.
*/
public function view($id = null)
{
$Product = new Proud();
$Product = $Product->findItem(array('Id = ' . $id));
$Client = new Client();
if (!$Product->Id) {
return $this->halt();
}
$Category = $Product->getCategory();
/* $this->getView()->set('Product', $Product); */
$this->getView()->set(array('Product' => $Product, 'Client' => $Client->findItem(array('Id = ' . $Product->CategoryId))));
$this->getView()->setMethod('view');
/*
if ( $Product->getCategory()->getLayout() instanceof Product_Layout_Custom )
{
$this->getView()->setMethod('custom');
}
elseif ( $Product->getCategory()->getLayout() instanceof Product_Layout_Common )
{
$this->getView()->setMethod('common');
}
$this->getView()->activeMenu = $Category;
$this->setContentPage($Category);
$Page = $this->getContentPage();
$Page->SeoTitle = $Product->SeoTitle ? $Product->SeoTitle : $Product->Name;
$Page->SeoDescription = $Product->SeoDescription;
$Page->SeoKeywords = $Product->SeoKeywords;
*/
return $this->getView()->render();
}
示例8: testClientCanBeCreated
public function testClientCanBeCreated()
{
$a = new GiroAccount(123, 250);
$b = new Client($a);
$b->setAccount($a);
$c = null;
}
示例9: request
/**
* Perform a cURL request and decode the JSON response.
* Can throw and exception if the request can't be successfully executed.
*
* @param Client $client The client making the request, so we can extract
* the API Key and Password
* @param string $resource The API resource/path to request
* @param string $method The HTTP verb to use (GET|POST|PUT|DELETE)
* @param array $data Collection of data to be sent with the request
*
* @return string Decoded JSON object
*/
public static function request($client, $resource, $method, $data = array())
{
$curl = curl_init();
$url = self::$endPoint . $resource;
if (sizeof($data)) {
if ($method == 'POST') {
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
} elseif ($method == 'GET') {
$url .= '?' . http_build_query($data);
}
}
if ($method == 'POST' && sizeof($data)) {
$body = json_encode($data);
} else {
$body = '';
}
$nonce = (int) (microtime(true) * 1000000.0);
$message = $nonce . $url . $body;
$signature = hash_hmac('sha256', $message, $client->getApiPass());
$headers = array('Access-Key:' . $client->getApiKey(), 'Access-Nonce:' . $nonce, 'Content-Type:' . 'application/json', 'Access-Signature:' . $signature);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curl);
if ($response === false) {
throw new \Exception('No response from curl_exec in ' . __METHOD__);
}
$headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$responseBody = substr($response, $headerSize);
curl_close($curl);
return json_decode($responseBody);
}
示例10: setUp
public function setUp()
{
// connect to mongo
$client = new Client(getenv('PHPMONGO_DSN') ? getenv('PHPMONGO_DSN') : null);
// select database
$this->database = $client->getDatabase('test');
}
示例11: get
/**
* Get instance of connection
*
* @param string $name connection identifier
* @return \Sokil\Mongo\Client
* @throws \Sokil\Mongo\Exception
*/
public function get($name)
{
// get from cache
if (isset($this->pool[$name])) {
return $this->pool[$name];
}
// check if connection exists
if (!isset($this->configuration[$name])) {
throw new Exception('Connection with name ' . $name . ' not found');
}
// check if dsn exists
if (!isset($this->configuration[$name]['dsn'])) {
$this->configuration[$name]['dsn'] = null;
}
// check if connect options exists
if (empty($this->configuration[$name]['connectOptions'])) {
$this->configuration[$name]['connectOptions'] = null;
}
// init client
$client = new Client($this->configuration[$name]['dsn'], $this->configuration[$name]['connectOptions']);
if (isset($this->configuration[$name]['mapping'])) {
$client->map($this->configuration[$name]['mapping']);
}
if (isset($this->configuration[$name]['defaultDatabase'])) {
$client->useDatabase($this->configuration[$name]['defaultDatabase']);
}
$this->pool[$name] = $client;
return $client;
}
示例12: add
public function add(Request $request)
{
// Ask if we are supplying our own data or requesting it from the server
if ($request->has('remote') && ($request->remote = 'true')) {
$client = new Client();
$res = $client->request('GET', 'http://fsvaos.net/api/central/aircraft', ['query' => ['icao' => $request->icao]])->getBody();
// Add the airport to the database
$data = json_decode($res, true);
$aircraft = new Aircraft();
//return dd($data);
$aircraft->name = $data[0]['name'];
$aircraft->icao = $data[0]['icao'];
$aircraft->maxgw = $data[0]['maxgw'];
$aircraft->maxpax = $data[0]['maxpax'];
$aircraft->range = $data[0]['range'];
$aircraft->registration = $request->input('registration');
$aircraft->enabled = true;
$aircraft->hub = $request->input('hub');
$aircraft->save();
} else {
// insert manual entry system.
$aircraft = new Aircraft();
//return dd($data);
$aircraft->name = $request->input('name');
$aircraft->icao = $request->input('icao');
$aircraft->maxgw = $request->input('maxgw');
$aircraft->maxpax = $request->input('maxpax');
$aircraft->range = $request->input('range');
$aircraft->registration = $request->input('registration');
$aircraft->enabled = true;
$aircraft->hub = $request->input('hub');
$aircraft->save();
}
}
示例13: testAudioInstanceCreatedForWord
public function testAudioInstanceCreatedForWord()
{
$c = new Client();
$c->setApiKey('foobar');
$request = $c->wordAudio('bar');
$this->assertInstanceOf('Picnik\\Requests\\Word\\AudioRequest', $request);
}
示例14: 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);
}
示例15: setUp
public function setUp()
{
// connect to mongo
$client = new Client();
// select database
$this->database = $client->getDatabase('test');
}