本文整理汇总了PHP中Zend_Rest_Client::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Rest_Client::__construct方法的具体用法?PHP Zend_Rest_Client::__construct怎么用?PHP Zend_Rest_Client::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Rest_Client
的用法示例。
在下文中一共展示了Zend_Rest_Client::__construct方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($uri, $email, $password, $consumer_key, $consumer_secret, $oauth_realm, $cookieJarFile = './OX3_Api_CookieJar.txt', $sso = array(), $proxy = array())
{
parent::__construct($uri);
$aUrl = parse_url($uri);
if (empty($sso)) {
$sso = array('siteUrl' => 'https://sso.openx.com/api/index/initiate', 'requestTokenUrl' => 'https://sso.openx.com/api/index/initiate', 'accessTokenUrl' => 'https://sso.openx.com/api/index/token', 'authorizeUrl' => 'https://sso.openx.com/login/login', 'loginUrl' => 'https://sso.openx.com/login/process');
}
// Set the proxy['adapter'] if $proxy config was passed in
if (!empty($proxy)) {
$proxy['adapter'] = 'Zend_Http_Client_Adapter_Proxy';
}
// Initilize the cookie jar, from the $cookieJarFile if present
$client = self::getHttpClient();
$cookieJar = false;
if (is_readable($cookieJarFile)) {
$cookieJar = @unserialize(file_get_contents($cookieJarFile));
}
if (!$cookieJar instanceof Zend_Http_CookieJar) {
$cookieJar = new Zend_Http_CookieJar();
}
$client->setCookieJar($cookieJar);
$client->setConfig($proxy);
$result = $this->put('/a/session/validate');
// See if the openx3_access_token is still valid...
if ($result->isError()) {
// Get Request Token
$config = array('siteUrl' => $sso['siteUrl'], 'requestTokenUrl' => $sso['requestTokenUrl'], 'accessTokenUrl' => $sso['accessTokenUrl'], 'authorizeUrl' => $sso['authorizeUrl'], 'consumerKey' => $consumer_key, 'consumerSecret' => $consumer_secret, 'realm' => $oauth_realm);
$oAuth = new OX3_Oauth_Consumer($config);
$requestToken = $oAuth->getRequestToken();
// Authenticate to SSO
$loginClient = new Zend_Http_Client($sso['loginUrl']);
$loginClient->setCookieJar();
$loginClient->setConfig($proxy);
$loginClient->setParameterPost(array('email' => $email, 'password' => $password, 'oauth_token' => $requestToken->getToken()));
$loginClient->request(Zend_Http_Client::POST);
$loginBody = $loginClient->getLastResponse()->getBody();
// Parse response, sucessful headless logins will return oob?oauth_token=<token>&oauth_verifier=<verifier> as the body
if (substr($loginBody, 0, 4) == 'oob?') {
$vars = array();
@parse_str(substr($loginBody, 4), $vars);
if (empty($vars['oauth_token'])) {
throw new Exception('Error parsing SSO login response');
}
// Swap the (authorized) request token for an access token:
$accessToken = $oAuth->getAccessToken($vars, $requestToken)->getToken();
$client->setCookie(new Zend_Http_Cookie('openx3_access_token', $accessToken, $aUrl['host']));
$result = $this->put('/a/session/validate');
if ($result->isSuccessful()) {
file_put_contents($cookieJarFile, serialize($client->getCookieJar()), LOCK_EX);
chmod($cookieJarFile, 0666);
}
} else {
throw new Exception('SSO Authentication error');
}
}
}
示例2: __construct
public function __construct($serviceUrl = null)
{
if (is_null($serviceUrl)) {
$serviceUrl = Zend_Registry::get('config')->service->users->url;
if (!$serviceUrl) {
throw new Kwf_Exception("'service.users.url' not defined in config (usually defined in KWF config)");
}
}
parent::__construct($serviceUrl);
}
示例3: __construct
public function __construct($type)
{
$this->_type = $type;
$app = $GLOBALS['application']->getOption('app');
$message_config = $app['messages'][$type];
$server = $message_config['server'];
$context = $message_config['context'];
unset($message_config['server']);
unset($message_config['context']);
$this->_messages = new StdClass();
foreach ($message_config as $key => $method) {
$key = str_replace(' ', '', ucwords(str_replace('_', ' ', $key)));
$this->_messages->{$key} = $context . $method;
}
Zend_Rest_Client::__construct($server);
$this->getHttpClient()->setHeaders('Accept-Encoding', 'plain');
}
示例4: __construct
/**
* @param string $ps_url The url to connect to
* @param array $ps_options An array of options:
* timeout = the number of seconds to wait for a response before throwing an exception. Default is 30 seconds.
*/
public function __construct($ps_uri = null, $pa_options = null)
{
self::getHttpClient()->setCookieJar(true);
self::getHttpClient()->setConfig(array("timeout" => isset($pa_options['timeout']) && (int) $pa_options['timeout'] > 0 ? (int) $pa_options['timeout'] : 30));
parent::__construct($ps_uri);
}