本文整理汇总了PHP中client类的典型用法代码示例。如果您正苦于以下问题:PHP client类的具体用法?PHP client怎么用?PHP client使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* make the call to the API
*
* @param Request
* @return Response
*/
public function send($request)
{
try {
# if it was successful, return the response
return $this->client->send($request)->json();
} catch (\GuzzleHttp\Exception\ClientException $e) {
# if it was unsuccessful then return the error that was thrown
return $e->getResponse();
}
}
示例2: it_should_throw_a_bad_request_exception_when_the_response_is_a_400
public function it_should_throw_a_bad_request_exception_when_the_response_is_a_400()
{
$productJson = '{ "sku": "sku1" }';
$stream = Stream::factory('{"code":400,"message":"You must specify at least one valid identifier."}');
$mock = new Mock([new response(400, [], $stream)]);
$client = new client();
$client->getemitter()->attach($mock);
$this->beConstructedWith($client, $this->getDefaultConfigArray());
$this->shouldThrow('Flubit\\BadRequestException')->during('post', ['product', $productJson]);
}
示例3: content
public function content()
{
$data = $this->input['data'];
$content_client_relation = $data['content_client_relation'];
$content_relation = $data['content_relation'];
$content = $data['content'];
if (!$content_client_relation || !$content_relation || !$content) {
$this->errorOutput('NO_DATA');
}
$bundle_id = $content['bundle_id'];
$module_id = $content['module_id'];
$struct_id = $content['struct_id'];
//content process
$syn_content = $this->syn_obj->get_content_in_site($content['id'], $content['site_id']);
$update_contentarr = $content;
unset($update_contentarr['id']);
if ($syn_content) {
//struct_table update process
$this->struct($bundle_id, $module_id, $struct_id, $data, 'update', $syn_content['expand_id']);
unset($update_contentarr['syn_cid'], $update_contentarr['expand_id'], $update_contentarr['plan_set_id'], $update_contentarr['bundle_id'], $update_contentarr['module_id'], $update_contentarr['struct_id'], $update_contentarr['content_fromid']);
$this->obj->update('content', ' id=' . $syn_content['id'], $update_contentarr);
$content_id = $syn_content['id'];
} else {
//struct_table insert process
$update_contentarr['expand_id'] = $this->struct($bundle_id, $module_id, $struct_id, $data);
$update_contentarr['syn_cid'] = $content['id'];
$content_id = $this->obj->insert('content', $update_contentarr);
}
//content_relation process
$syn_content_relation = $this->syn_obj->get_content_relation_by_columnid($content_id, $content_relation['column_id']);
$update_content_relationarr = $content_relation;
unset($update_content_relationarr['id']);
if ($syn_content_relation) {
unset($update_content_relationarr['syn_rid'], $update_content_relationarr['content_id'], $update_content_relationarr['order_id'], $update_contentarr['bundle_id'], $update_contentarr['module_id'], $update_contentarr['struct_id']);
$this->obj->update('content_relation', ' id=' . $syn_content_relation['id'], $update_content_relationarr);
$content_relation_id = $syn_content_relation['id'];
} else {
$update_content_relationarr['syn_rid'] = $content_relation['id'];
$update_content_relationarr['content_id'] = $content_id;
$content_relation_id = $this->obj->insert('content_relation', $update_content_relationarr);
$this->obj->update('content_relation', ' id=' . $content_relation_id, array('order_id' => $content_relation_id));
//add content_client_relation
//get client
include CUR_CONF_PATH . 'lib/client.class.php';
$client_obj = new client();
$client_typearr = $client_obj->get_all_client();
foreach ($client_typearr as $kct => $vct) {
$content_client_data['client_type'] = $vct['id'];
$content_client_data['relation_id'] = $content_relation_id;
$this->obj->insert('content_client_relation', $content_client_data);
}
}
}
示例4: show
/**
* @Description : 获取发布库内容
* @Author : dong(dong@hoge.cn)
* @Category : publishcontent
* @Date : 2014-2-14
* @LastUpdateDate : 2014-2-14
* @Copyright : hogesoft
* @Param : site_id(站点id);column_id(栏目id,多个逗号隔开);client_type(终端id);
* @Return : json
*/
public function show()
{
$site_id = $column_id = '';
$content_data = array();
$id = urldecode($this->input['_id']);
$app = urldecode($this->input['con_app']) == 'all' ? '' : urldecode($this->input['con_app']);
//查询出站点下模块的内容
//$offset = $this->input['offset'] ? intval(urldecode($this->input['offset'])) : 0;
$page = $this->input['page'] ? intval(urldecode($this->input['page'])) : 1;
$count = $this->input['offset'] ? intval(urldecode($this->input['offset'])) : 20;
$offset = $count * ($page - 1);
$content_data = $this->obj->get_content_allinfo($this->get_condition(), $offset, $count, $this->other_field);
if ($content_data['col_id_str']) {
$col_parent = $this->column->get_col_parents($content_data['col_id_str']);
$column_datas = $this->column->get_column_by_id(' id,name,site_id,column_dir,relate_dir,fid,childdomain,father_domain,custom_content_dir,col_con_maketype ', $content_data['col_id_str'], 'id');
}
if ($content_data['site_id_arr']) {
$site_datas = $this->column->get_site(' id,site_name,weburl,sub_weburl,custom_content_dir ', ' AND id in(' . implode(',', $content_data['site_id_arr']) . ')', 'id');
}
unset($content_data['col_id_str']);
unset($content_data['site_id_arr']);
foreach ($content_data as $k => $v) {
$content_data[$k]['state'] = $v['status'];
if ($v['outlink']) {
$content_data[$k]['content_url'] = stripos($v['outlink'], 'http') === 0 ? $v['outlink'] : 'http://' . $v['outlink'];
} else {
$v['column_id'] = $v['use_maincolumn'] ? $v['main_column_id'] : $v['column_id'];
$content_data[$k]['content_url'] = mk_content_url($site_datas[$v['site_id']], $column_datas[$v['column_id']], $v);
}
}
//取出应用模块
$appdata = $this->obj->get_app();
$appchilddata = $this->obj->get_app_child($app);
//取出所有客户端
include_once CUR_CONF_PATH . 'lib/client.class.php';
$client_obj = new client();
$client = $client_obj->get_all_client('*', '', 'id');
$sql = "SELECT COUNT(*) AS total" . $this->other_field . " FROM " . DB_PREFIX . "content_client_relation cr LEFT JOIN " . DB_PREFIX . "content_relation r ON cr.relation_id=r.id WHERE 1 " . $this->get_condition();
$pagearr = $this->db->query_first($sql);
$pagearr['offset'] = $count;
$pagearr['count'] = $count;
$pagearr['total_page'] = ceil($pagearr['total'] / $count);
$pagearr['current_page'] = floor($offset / $count) + 1;
$alldata['content_data'] = $content_data;
$alldata['col_parent'] = $col_parent;
$alldata['app_data'] = $appdata;
$alldata['appchild_data'] = $appchilddata;
$alldata['client'] = $client;
$alldata['page'] = $pagearr;
$this->addItem($alldata);
$this->output();
}
示例5: get_num_rows
function get_num_rows(client $client, $table_name)
{
//TODO: check client's cookie (setting) not to do all these selects
if (false) {
return "";
}
$query = "select count(*) from " . $table_name . ";";
$res = odbc_exec($client->get_connection(), $query);
if ($res === false) {
return "unknown";
} else {
return format_num_rows(odbc_result($res, 1));
}
}
示例6: testApi
/**
* @param array $request
* @param array $response
*
* @dataProvider requestsApi
*/
public function testApi($request, $response)
{
foreach ($request as $key => $value) {
if (is_null($value)) {
unset($request[$key]);
}
}
$this->client->request('GET', $this->client->generate('oro_api_get_search'), $request);
$result = $this->client->getResponse();
ToolsAPI::assertJsonResponse($result, 200);
$result = json_decode($result->getContent(), true);
//compare result
$this->assertEqualsResponse($response, $result);
}
示例7: add
public function add()
{
$form = array('building_id' => '', 'name' => '', 'index' => '', 'img_uri' => '', 'active' => '');
$errors = $form;
if ($_POST) {
$post = new Validation($_POST);
$post->pre_filter('trim', true);
$post->add_rules('buildings_id', 'required', 'digit');
$post->add_rules('name', 'required');
$post->add_rules('index', 'required');
$post->add_rules('img_uri', 'required');
$post->add_rules('active', 'required');
if ($post->validate()) {
// check for invilid
$form = arr::overwrite($form, $post->as_array());
$people = new Person_Model();
$result = $people->save($this->input->get('person'), $person_id);
} else {
$form = arr::overwrite($form, $post->as_array());
client::validation_results(arr::overwrite($errors, $post->errors('hiring_employee_form_validations')));
client::messageSend("There were errors in some fields", E_USER_WARNING);
}
}
$building = new Building_Model();
$buildings_list = $building->select_list();
$this->template->title = 'Seating::Spaces::Add';
$this->template->content = new View('pages/spaces_add');
$this->template->content->form = $form;
$this->template->content->buildings_list = $buildings_list;
}
示例8: createNote
public static function createNote($pack)
{
$pack->auth->permission = "read_write";
if (!users::authenticateUser($pack->auth)) {
return new return_package(6, NULL, "Failed Authentication");
}
if ($pack->media) {
$pack->media->auth = $pack->auth;
$pack->media->game_id = $pack->game_id;
$pack->media_id = media::createMedia($pack->media)->data->media_id;
}
$game = games::getGame($pack);
$pack->note_id = dbconnection::queryInsert("INSERT INTO notes (" . "game_id," . "user_id," . (isset($pack->name) ? "name," : "") . (isset($pack->description) ? "description," : "") . (isset($pack->media_id) ? "media_id," : "") . "published," . "created" . ") VALUES (" . "'" . $pack->game_id . "'," . "'" . $pack->auth->user_id . "'," . (isset($pack->name) ? "'" . addslashes($pack->name) . "'," : "") . (isset($pack->description) ? "'" . addslashes($pack->description) . "'," : "") . (isset($pack->media_id) ? "'" . addslashes($pack->media_id) . "'," : "") . ($game->data->moderated ? "'PENDING'" : "'AUTO'") . "," . "CURRENT_TIMESTAMP" . ")");
if ($pack->trigger) {
$scene_id = dbconnection::queryObject("SELECT * FROM user_game_scenes WHERE user_id = '{$pack->auth->user_id}' AND game_id = '{$pack->game_id}'")->scene_id;
if (!$scene_id) {
$scene_id = $game->data->intro_scene_id;
}
$instance_id = dbconnection::queryInsert("INSERT INTO instances (game_id, object_id, object_type, created) VALUES ('{$pack->game_id}', '{$pack->note_id}', 'NOTE', CURRENT_TIMESTAMP)");
$trigger_id = dbconnection::queryInsert("INSERT INTO triggers (game_id, instance_id, scene_id, type, latitude, longitude, infinite_distance, created) VALUES ( '{$pack->game_id}', '{$instance_id}', '{$scene_id}', 'LOCATION', '{$pack->trigger->latitude}', '{$pack->trigger->longitude}', '1', CURRENT_TIMESTAMP);");
}
//allow for 'tag_id' in API, but really just use object_tags
if ($pack->tag_id) {
dbconnection::queryInsert("INSERT INTO object_tags (game_id, object_type, object_id, tag_id, created) VALUES ('{$pack->game_id}', 'NOTE', '{$pack->note_id}', '{$pack->tag_id}', CURRENT_TIMESTAMP)");
}
client::logPlayerCreatedNote($pack);
games::bumpGameVersion($pack);
return notes::getNote($pack);
}
示例9: generateUserInfo
/**
* 通过调用信任登陆相关用户接口生成用户info
*
* @param string $code
* @return string
*/
public function generateUserInfo()
{
$args = ['access_token' => $this->getAccessToken()];
$msg = client::get($this->getUrl('userinfo'), ['query' => $args])->json();
if ($msg['error']) {
throw new \LogicException("error :" . $msg['error_code'] . "msg :" . $msg['error']);
}
return $this->convertStandardUserInfo($msg);
}
示例10: show_filter
function show_filter()
{
global $TPL;
global $defaults;
$_FORM = client::load_form_data($defaults);
$arr = client::load_client_filter($_FORM);
is_array($arr) and $TPL = array_merge($TPL, $arr);
include_template("templates/clientListFilterS.tpl");
}
示例11: generateUserInfo
public function generateUserInfo()
{
$args = ['access_token' => $this->getAccessToken(), 'oauth_consumer_key' => $this->getAppKey(), 'openid' => $this->getOpenId()];
$msg = client::get($this->getUrl('userinfo'), ['query' => $args])->json();
if ($msg['ret'] !== 0) {
throw new \LogicException(app::get('sysuser')->_('参数错误!'));
}
return $this->convertStandardUserInfo($msg);
}
示例12: addOrder
function addOrder()
{
if ($_POST['cl_id'] < 0) {
$client = new client();
$client->addClient();
$client->existClient();
}
$ord_cl_id = $_POST['cl_id'];
$ord_bike = $_POST['ord_bike'];
//$ord_start_job = strtotime($_POST['ord_date_start']);
$ord_start_job = $_POST['ord_date_start'];
$ord_internal_note = $_POST['ord_internal_note'];
$query = "INSERT INTO `order`(`ord_cl_id`,`ord_bike`,`ord_start_job`,`ord_internal_note`) \n\t\t\t\t\t\t\tVALUES ('{$ord_cl_id}','{$ord_bike}', STR_TO_DATE('{$ord_start_job}','%d.%m.%Y'),'{$ord_internal_note}')";
$database = new database();
$database->dbQuery($query);
//return $query;
return $_POST['cl_id'];
}
示例13: getCoordinatesForQuery
/**
*
* Get the coordinates for a query
*
* @param string $query
* @return array
* @throws \Exception
*/
public function getCoordinatesForQuery($query)
{
if ($query == '') {
return false;
}
$request = $this->client->get('http://maps.googleapis.com/maps/api/geocode/json');
$request->getQuery()->set('address', $query)->set('sensor', 'false');
$response = $request->send();
if ($response->getStatusCode() != 200) {
throw new \Exception('could not connect to googleapis.com/maps/api');
}
$fullResponse = $response->json();
if (count($fullResponse['results'])) {
$geocoderResult = ['lat' => $fullResponse['results'][0]['geometry']['location']['lat'], 'lng' => $fullResponse['results'][0]['geometry']['location']['lng'], 'accuracy' => $fullResponse['results'][0]['geometry']['location_type']];
} else {
$geocoderResult = ['lat' => 0, 'lng' => 0, 'accuracy' => self::RESULT_NOT_FOUND];
}
return $geocoderResult;
}
示例14: createNoteComment
public static function createNoteComment($pack)
{
$pack->auth->permission = "read_write";
if (!users::authenticateUser($pack->auth)) {
return new return_package(6, NULL, "Failed Authentication");
}
$pack->note_comment_id = dbconnection::queryInsert("INSERT INTO note_comments (" . "game_id," . "note_id," . "user_id," . (isset($pack->name) ? "name," : "") . (isset($pack->description) ? "description," : "") . "created" . ") VALUES (" . "'" . $pack->game_id . "'," . "'" . $pack->note_id . "'," . "'" . $pack->auth->user_id . "'," . (isset($pack->name) ? "'" . addslashes($pack->name) . "'," : "") . (isset($pack->description) ? "'" . addslashes($pack->description) . "'," : "") . "CURRENT_TIMESTAMP" . ")");
client::logPlayerCreatedComment($pack);
games::bumpGameVersion($pack);
return note_comments::getNoteComment($pack);
}
示例15: find
static function find($search_id)
{
$found_client = null;
$clients = client::getAll();
foreach (clients as $client) {
$id = $client->getId();
if ($id == $search_id) {
$found_client = $client;
}
}
return $found_client;
}