本文整理汇总了PHP中Guzzle\Http\Message\Response::getEffectiveUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::getEffectiveUrl方法的具体用法?PHP Response::getEffectiveUrl怎么用?PHP Response::getEffectiveUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Http\Message\Response
的用法示例。
在下文中一共展示了Response::getEffectiveUrl方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mfForResponse
function mfForResponse(Guzzle\Http\Message\Response $resp)
{
$html = $resp->getBody(true);
$host = parse_url($resp->getEffectiveUrl(), PHP_URL_HOST);
if ($host == 'twitter.com') {
return Mf2\Shim\parseTwitter($html, $resp->getEffectiveUrl());
} elseif ($host == 'facebook.com') {
return Mf2\Shim\parseFacebook($html, $resp->getEffectiveUrl());
} else {
return Mf2\parse($html, $resp->getEffectiveUrl());
}
}
示例2: resolveRequest
private function resolveRequest(\Guzzle\Http\Message\Request $request)
{
try {
$this->lastResponse = $request->send();
} catch (\Guzzle\Http\Exception\TooManyRedirectsException $tooManyRedirectsException) {
if ($this->hasRequestHistory($request)) {
$this->lastResponse = $this->getRequestHistory($request)->getLastResponse();
} else {
return $request->getUrl();
}
} catch (\Guzzle\Http\Exception\BadResponseException $badResponseException) {
if ($this->getConfiguration()->getRetryWithUrlEncodingDisabled() && !$this->getConfiguration()->getHasRetriedWithUrlEncodingDisabled()) {
$this->getConfiguration()->setHasRetriedWithUrlEncodingDisabled(true);
return $this->resolveRequest($this->deEncodeRequestUrl($request));
} else {
$this->lastResponse = $badResponseException->getResponse();
}
}
if ($this->getConfiguration()->getHasRetriedWithUrlEncodingDisabled()) {
$this->getConfiguration()->setHasRetriedWithUrlEncodingDisabled(false);
}
if ($this->getConfiguration()->getFollowMetaRedirects()) {
$metaRedirectUrl = $this->getMetaRedirectUrlFromLastResponse();
if (!is_null($metaRedirectUrl) && !$this->isLastResponseUrl($metaRedirectUrl)) {
return $this->resolve($metaRedirectUrl);
}
}
return $this->lastResponse->getEffectiveUrl();
}
示例3: createPutRequest
/**
* Create a tailored PUT request for each file
*
* @param Response $response
* @return \Guzzle\Http\Message\EntityEnclosingRequestInterface
*/
protected function createPutRequest(Response $response)
{
$segments = Url::factory($response->getEffectiveUrl())->getPathSegments();
$name = end($segments);
// Retrieve content and metadata
$file = $this->newContainer->dataObject()->setName($name);
$file->setMetadata($response->getHeaders(), true);
return $this->getClient()->put($file->getUrl(), $file::stockHeaders($file->getMetadata()->toArray()), $response->getBody());
}
示例4: fromResponse
/**
* Construct a TransferPart from a HTTP response delivered by the API.
*
* @param Response $response
* @param int $partNumber
* @return TransferPart
*/
public static function fromResponse(Response $response, $partNumber = 1)
{
$responseUri = Url::factory($response->getEffectiveUrl());
$object = new self();
$object->setPartNumber($partNumber)->setContentLength($response->getHeader(Header::CONTENT_LENGTH))->setETag($response->getHeader(Header::ETAG))->setPath($responseUri->getPath());
return $object;
}
示例5: getEffectiveUrl
/**
* {@inheritdoc}
*/
public function getEffectiveUrl()
{
return $this->response->getEffectiveUrl();
}
示例6: pushLinksForResponse
function pushLinksForResponse(Guzzle\Http\Message\Response $resp)
{
$self = null;
$hubs = [];
$linkHeader = $resp->getHeader('link');
if ($linkHeader instanceof Guzzle\Http\Message\Header\Link) {
$links = $linkHeader->getLinks();
foreach ($links as $link) {
if (strpos(" {$link['rel']} ", ' self ') !== false) {
$self = $link['url'];
}
if (strpos(" {$link['rel']} ", ' hub ') !== false) {
$hubs[] = $link['url'];
}
}
}
if (strpos($resp->getContentType(), 'html') !== false) {
$mf = Mf2\parse($resp->getBody(true), $resp->getEffectiveUrl());
if (!empty($mf['rels']['hub'])) {
$hubs = array_merge($hubs, $mf['rels']['hub']);
}
if (!empty($mf['rels']['self']) and $self === null) {
$self = $mf['rels']['self'][0];
}
}
return ['self' => $self, 'hub' => $hubs];
}