本文整理汇总了PHP中Zend\Http\Client::setParameterGet方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::setParameterGet方法的具体用法?PHP Client::setParameterGet怎么用?PHP Client::setParameterGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Http\Client
的用法示例。
在下文中一共展示了Client::setParameterGet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeQuery
/**
* @param $select
* @param $from
* @param $where
* @param $format
*/
public function executeQuery($select, $from, $where, $format = 'json')
{
$yql_query = "select {$select} from {$from} where {$where} ";
$this->client->setParameterGet(array('q' => $yql_query, 'format' => $format));
$response = $this->client->send();
/* @var $response \Zend\Http\Response */
if ($response->isSuccess()) {
return $response->getBody();
} else {
throw new \Exception('Error - Response code: ' . $response->getStatusCode() . ' - query - ' . $yql_query);
}
}
示例2: verify
/**
* Verify the user input
*
* @param $response
*
* @return Response
* @throws \Exception
*/
public function verify($response)
{
if (!$this->secretKey) {
throw new Exception('Missing secret key');
}
$params = array('secret' => $this->secretKey, 'response' => $response);
if ($this->ip !== null) {
$params['ip'] = $this->ip;
}
$this->httpClient->setUri(self::VERIFY_SERVER);
$this->httpClient->setParameterGet($params);
if ($this->options) {
$this->httpClient->setOptions($this->options);
}
$response = $this->httpClient->send();
return new CaptchaResponse($response);
}
示例3: request
/**
* @param string $method
* @param string $url
* @param array [optional] $params
*/
public function request($method, $url, $params = [])
{
$this->httpClient->setUri($this->moduleOptions->getApiUrl() . '/' . ltrim($url, '/'));
$this->httpClient->setMethod($method);
if (!is_null($params)) {
if ($method == 'post' || $method == 'put') {
$this->httpClient->setEncType(HttpClient::ENC_FORMDATA);
$this->httpClient->setParameterPost($params);
} else {
$this->httpClient->setEncType(HttpClient::ENC_URLENCODED);
$this->httpClient->setParameterGet($params);
}
}
$response = $this->httpClient->send();
$data = json_decode($response->getBody(), true);
return $data;
}
示例4: prepareHttpRequest
/**
* Prepare req
*
* @param Request $request
* @return Client
* @author Paolo Agostinetto <paul.ago@gmail.com>
*/
protected function prepareHttpRequest(Request $request)
{
$client = new Client("https://api.thumbalizr.com/", array('adapter' => 'Zend\\Http\\Client\\Adapter\\Curl', 'curloptions' => array(CURLOPT_FOLLOWLOCATION => TRUE, CURLOPT_SSL_VERIFYPEER => FALSE)));
$client->setStream();
// Use temp file
$client->setParameterGet(array("api_key" => $this->apiKey, "quality" => $request->getQuality(), "width" => $request->getWidth(), "encoding" => $request->getEncoding(), "delay" => $request->getDelay(), "mode" => $request->getMode(), "bwidth" => $request->getBrowserWidth(), "bheight" => $request->getBrowserHeight(), "url" => $request->getUrl() . "&rnd=" . rand(100000, 999999999), "generate" => 0));
return $client;
}
示例5: delete
/**
* @param string|array $identities
*
* @return bool
*/
public function delete($identities)
{
$this->_client->setUri(implode('/', [self::getConfig()['uri'], 'file/delete']));
if (!is_array($identities)) {
$identities = (array) $identities;
}
$this->_client->setParameterGet(['ids' => $identities]);
return $this->_client->send()->getStatusCode() == 200;
}
示例6: getGeocodedLatitudeAndLongitude
public function getGeocodedLatitudeAndLongitude($address)
{
$client = new Client();
$client->setUri($this->_url);
$client->setParameterGet(array('address' => urlencode($address), 'sensor' => 'false'));
$client->setMethod('GET');
$result = $client->send();
$response = Decoder::decode($result->getBody(), Json::TYPE_OBJECT);
return $response;
}
示例7: cancel
public function cancel($reference)
{
$url = $this->_server . "/nfe2/cancelar/";
$client = new Client($url);
$client->setMethod('GET');
$client->setParameterGet(array('token' => $this->_token, 'ref' => $reference, 'justificativa' => $this->_justification));
$response = $client->send();
$this->_responseBody = $response->getBody();
return $response->isSuccess();
}
示例8: connect
public function connect($uri, $post = false, $params = null)
{
$client = new Client($uri, array('timeout' => 600, 'sslverifypeer' => false));
if (!$post) {
$client->setParameterGet($params);
}
$request = $client->getRequest();
$response = $client->dispatch($request);
return $response;
}
示例9: toCoordinates
/**
* used by the beo plugin only. We can hardcode the geoCoderUrl for the moment
*
* @param $input
*
* @return array|mixed|string
*/
public function toCoordinates($input)
{
$client = new Client('http://api.cross-solution.de/geo');
$client->setMethod('GET');
$client->setParameterGet(array('q' => $input, 'country' => 'DE', 'coor' => 1, 'zoom' => 1, 'strict' => 0));
$response = $client->send();
$result = $response->getBody();
$result = json_decode($result);
$result = (array) $result->result;
return $result;
}
示例10: search
private function search($query, $geolocate)
{
$query = urlencode($query);
$client = new Client();
$client->setAdapter('Zend\\Http\\Client\\Adapter\\Curl');
$client->setOptions(['timeout' => 60]);
$client->setAuth(BING_SEARCH_API_KEY, BING_SEARCH_API_KEY);
$client->setUri('https://api.datamarket.azure.com/Bing/Search/v1/Web');
$searchParams = $geolocate ? ['Market' => "'es-Cl'", 'Latitude' => '-33.45', 'Longitude' => '-70.6667', 'Query' => "'{$query}'", '$format' => 'json'] : ['Query' => "'{$query}'", '$format' => 'json'];
$client->setParameterGet($searchParams);
$response = $client->send();
return $response->isSuccess() ? json_decode($response->getBody()) : null;
}
示例11: getToken
public function getToken()
{
if ($this->session->fbToken && $this->session->fbTokenExpires) {
if (time() <= $this->session->fbTokenExpires) {
return $this->session->fbToken;
}
}
$code = $this->getCode();
$this->http->setUri(self::FACEBOOK_AUTH_URI);
$this->http->setParameterGet(array('client_id' => $this->fbClientId, 'redirect_uri' => 'http://' . $_SERVER['HTTP_HOST'] . '/', 'client_secret' => $this->fbSecret, 'code' => $code));
$response = $this->http->send();
if ($response->getStatusCode() != \Zend\Http\Response::STATUS_CODE_200) {
throw new Exception\AuthException('Bad response from Facebook OAuth');
}
parse_str($response->getBody(), $parsedResponse);
if (!array_key_exists('access_token', $parsedResponse) || !array_key_exists('expires', $parsedResponse)) {
throw new Exception\AuthException('Bad parse from Facebook OAuth');
}
$this->session->fbToken = $parsedResponse['access_token'];
$this->session->fbTokenExpires = time() + $parsedResponse['expires'];
$this->session->offsetUnset('fbCode');
return $this->session->fbToken;
}
示例12: callRaynetcrmRestApi
/**
* Requests RAYNET Cloud CRM REST API. Check https://s3-eu-west-1.amazonaws.com/static-raynet/webroot/api-doc.html for any further details.
*
* @param $serviceName string URL service name
* @param $method string Http method
* @param $request array request
* @return \Zend\Http\Response response
*/
private function callRaynetcrmRestApi($serviceName, $method, $request)
{
$client = new Client('', array('adapter' => 'Zend\\Http\\Client\\Adapter\\Curl', 'curloptions' => array(CURLOPT_FOLLOWLOCATION => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false)));
$client->setMethod($method);
$client->setUri($this->buildUrl($serviceName));
$client->setHeaders(array('X-Instance-Name' => $this->fInstanceName, 'Content-Type' => 'application/json; charset=UTF-8'));
$client->setAuth($this->fUserName, $this->fApiKey);
if ($method === self::HTTP_METHOD_GET) {
$client->setParameterGet($request);
} else {
$client->setRawBody(Json::encode($request));
}
return $client->send();
}
示例13: testHttpAuthBasicWithCredentialsInUri
/**
* Test that we can properly use Basic HTTP authentication by specifying username and password
* in the URI
*
*/
public function testHttpAuthBasicWithCredentialsInUri()
{
$uri = str_replace('http://', 'http://%s:%s@', $this->baseuri) . 'testHttpAuth.php';
$this->client->setParameterGet(array('user' => 'alice', 'pass' => 'secret', 'method' => 'Basic'));
// First - fail password
$this->client->setUri(sprintf($uri, 'alice', 'wrong'));
$this->client->setMethod('GET');
$res = $this->client->send();
$this->assertEquals(401, $res->getStatusCode(), 'Expected HTTP 401 response was not recieved');
// Now use good password
$this->client->setUri(sprintf($uri, 'alice', 'secret'));
$this->client->setMethod('GET');
$res = $this->client->send();
$this->assertEquals(200, $res->getStatusCode(), 'Expected HTTP 200 response was not recieved');
}
示例14: request
public function request($service, array $params = [], $method = 'POST')
{
$result = false;
try {
$url = sprintf('https://api.superlogica.net/v2/financeiro%s', $service);
$client = new Client($url);
$client->setAdapter(new Curl());
$client->setMethod($method);
$client->setOptions(['curloptions' => [CURLOPT_HEADER => false, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false]]);
$client->setHeaders($this->authHeader);
if (!empty($params)) {
if ($method == 'GET') {
$client->setParameterGet($params);
} else {
$client->setParameterPost($params);
}
}
$response = $client->send();
if ($response->isSuccess()) {
$body = $response->getContent();
$json = Json\Json::decode($body, 1);
if (!empty($json[0]['status'])) {
if ($json[0]['status'] == '200') {
$result = $json;
}
} else {
$result = $json;
}
}
$isException = false;
} catch (\Zend\Http\Exception\RuntimeException $e) {
$isException = true;
} catch (\Zend\Http\Client\Adapter\Exception\RuntimeException $e) {
$isException = true;
} catch (Json\Exception\RuntimeException $e) {
$isException = true;
} catch (Json\Exception\RecursionException $e2) {
$isException = true;
} catch (Json\Exception\InvalidArgumentException $e3) {
$isException = true;
} catch (Json\Exception\BadMethodCallException $e4) {
$isException = true;
}
if ($isException === true) {
//código em caso de problemas no decode
}
return $result;
}
示例15: sendMsg
public function sendMsg($cellphones, $msg)
{
$client = new Client();
$client->setUri($this->smsConfig['uri']);
$query = array('CorpID' => $this->smsConfig['corpId'], 'Pwd' => $this->smsConfig['password'], 'Phones' => $cellphones, 'sContent' => iconv('UTF-8', 'GBK', $msg), 'ExtCode' => '', 'SendTime' => '');
$client->setParameterGet($query);
$client->setMethod(Request::METHOD_GET);
$response = $client->send();
if ($response->isSuccess()) {
$result = $response->getBody();
$code = (int) $result;
return array('msgCode' => $code, 'msgText' => $this->getMsg($code));
} else {
return array('msgCode' => -100, 'msgText' => '短信服务器器响应失败');
}
}