本文整理匯總了PHP中HttpClient::doRequest方法的典型用法代碼示例。如果您正苦於以下問題:PHP HttpClient::doRequest方法的具體用法?PHP HttpClient::doRequest怎麽用?PHP HttpClient::doRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類HttpClient
的用法示例。
在下文中一共展示了HttpClient::doRequest方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getActualConfig
public function getActualConfig()
{
if (!$this->_plugin instanceof FeedPlugin) {
return false;
}
$request = new HttpRequest();
$type = "pluginConfig";
$response = $this->getAction($this->getVersion());
$body = json_decode($response->getBody());
if (!isset($body->{$type})) {
return $response;
} else {
$url = $body->{$type};
}
$request->setUrl($url);
$request->setHeaders($this->getSignHeader());
$request->setHeaders($this->_defaultHeader());
$request->setMethod('GET');
/** @var HttpResponse $response */
$response = $this->_client->doRequest($request);
$body = json_decode($response->getBody());
return $body;
}
示例2: processImageByUpload
public function processImageByUpload($image, $app_session = null, $seq_number = null, $format = null)
{
$parameters = array("image" => $image == null ? null : '@' . $image, "app_session" => $app_session, "seq_number" => $seq_number, "format" => $format);
$response = HttpClient::doRequest(HttpMethod::POST, "https://" . self::PUBLIC_DNS . "/process/image/upload/", $parameters, $this->authHandlers, ContentType::MULTIPART, true);
return $response;
}
示例3: directions
public function directions($starting, $ending)
{
$parameters = array("starting" => $starting, "ending" => $ending);
$response = HttpClient::doRequest(HttpMethod::GET, "https://" . self::PUBLIC_DNS . "/directions", $parameters, $this->authHandlers, ContentType::FORM, true);
return $response;
}
開發者ID:RatanPaul,項目名稱:MapIT-Driving-Directions-API-Turorial,代碼行數:6,代碼來源:GoogleMapsDrivingDirections.php
示例4: HttpClient
/**
* Testing REST methods work by communicating with api.php
* api.php should be uploaded to a webserver, and the
* $url below updated with the URL of that script.
**/
require_once 'HttpRequest.php';
require_once 'HttpResponse.php';
require_once 'HttpClient.php';
$url = 'http://localhost/api.php';
$http = new HttpClient();
// GET request
echo "GET request\n";
$request = new HttpRequest();
$request->setUrl($url . '?name1=a&name2=b');
$request->setMethod('GET');
$response = $http->doRequest($request);
echo $response->getStatus(), ': ', $response->getBody(), "\n";
echo "\n";
// POST REQUEST
echo "POST request\n";
$body = "This is a new note to myself.";
$request = new HttpRequest();
$request->setUrl($url);
$request->setMethod('POST');
$request->setBody($body);
$request->addHeader('Content-Type', 'text/plain');
$response = $http->doRequest($request);
//echo "Response: "; print_r($response);
echo $response->getStatus(), ': ', $response->getBody(), "\n";
echo "\n";
// PUT REQUEST