Changeset View
Changeset View
Standalone View
Standalone View
src/future/oauth/PhutilOAuth1Future.php
Show All 17 Lines | final class PhutilOAuth1Future extends FutureProxy { | ||||
private $method = 'POST'; | private $method = 'POST'; | ||||
private $token; | private $token; | ||||
private $tokenSecret; | private $tokenSecret; | ||||
private $nonce; | private $nonce; | ||||
private $timestamp; | private $timestamp; | ||||
private $hasConstructedFuture; | private $hasConstructedFuture; | ||||
private $callbackURI; | private $callbackURI; | ||||
private $headers = array(); | private $headers = array(); | ||||
private $timeout; | |||||
public function setCallbackURI($callback_uri) { | public function setCallbackURI($callback_uri) { | ||||
$this->callbackURI = $callback_uri; | $this->callbackURI = $callback_uri; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setTimestamp($timestamp) { | public function setTimestamp($timestamp) { | ||||
$this->timestamp = $timestamp; | $this->timestamp = $timestamp; | ||||
Show All 35 Lines | public function setConsumerSecret(PhutilOpaqueEnvelope $consumer_secret) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setMethod($method) { | public function setMethod($method) { | ||||
$this->method = $method; | $this->method = $method; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setTimeout($timeout) { | |||||
$this->timeout = $timeout; | |||||
return $this; | |||||
} | |||||
public function getTimeout() { | |||||
return $this->timeout; | |||||
} | |||||
public function __construct($uri, $data = array()) { | public function __construct($uri, $data = array()) { | ||||
$this->uri = new PhutilURI((string)$uri); | $this->uri = new PhutilURI((string)$uri); | ||||
$this->data = $data; | $this->data = $data; | ||||
$this->setProxiedFuture(new HTTPSFuture($uri, $data)); | $this->setProxiedFuture(new HTTPSFuture($uri, $data)); | ||||
} | } | ||||
public function getSignature() { | public function getSignature() { | ||||
$params = array(); | $params = array(); | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | if (!$this->hasConstructedFuture) { | ||||
$future->addHeader('Authorization', $full_oauth_header); | $future->addHeader('Authorization', $full_oauth_header); | ||||
foreach ($this->headers as $header) { | foreach ($this->headers as $header) { | ||||
$future->addHeader($header[0], $header[1]); | $future->addHeader($header[0], $header[1]); | ||||
} | } | ||||
$this->headers = array(); | $this->headers = array(); | ||||
$timeout = $this->getTimeout(); | |||||
if ($timeout !== null) { | |||||
$future->setTimeout($timeout); | |||||
} | |||||
$this->hasConstructedFuture = true; | $this->hasConstructedFuture = true; | ||||
} | } | ||||
return $future; | return $future; | ||||
} | } | ||||
protected function didReceiveResult($result) { | protected function didReceiveResult($result) { | ||||
return $result; | return $result; | ||||
▲ Show 20 Lines • Show All 146 Lines • Show Last 20 Lines |