本文整理汇总了PHP中Auth_Yadis_Yadis::getHTTPFetcher方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth_Yadis_Yadis::getHTTPFetcher方法的具体用法?PHP Auth_Yadis_Yadis::getHTTPFetcher怎么用?PHP Auth_Yadis_Yadis::getHTTPFetcher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auth_Yadis_Yadis
的用法示例。
在下文中一共展示了Auth_Yadis_Yadis::getHTTPFetcher方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
function setUp()
{
$this->proxy_url = 'http://xri.example.com/';
$this->fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
$this->proxy = new Auth_Yadis_ProxyResolver($fetcher, $this->proxy_url);
$this->servicetype = 'xri://+i-service*(+forwarding)*($v*1.0)';
$this->servicetype_enc = 'xri%3A%2F%2F%2Bi-service%2A%28%2Bforwarding%29%2A%28%24v%2A1.0%29';
}
示例2: ping_broadcast_notice
function ping_broadcast_notice($notice)
{
if ($notice->is_local != Notice::LOCAL_PUBLIC && $notice->is_local != Notice::LOCAL_NONPUBLIC) {
return true;
}
# Array of servers, URL => type
$notify = common_config('ping', 'notify');
$profile = $notice->getProfile();
$tags = ping_notice_tags($notice);
foreach ($notify as $notify_url => $type) {
switch ($type) {
case 'xmlrpc':
case 'extended':
$req = xmlrpc_encode_request('weblogUpdates.ping', array($profile->nickname, common_local_url('showstream', array('nickname' => $profile->nickname)), common_local_url('shownotice', array('notice' => $notice->id)), common_local_url('userrss', array('nickname' => $profile->nickname)), $tags));
$request = HTTPClient::start();
$request->setConfig('connect_timeout', common_config('ping', 'timeout'));
$request->setConfig('timeout', common_config('ping', 'timeout'));
try {
$httpResponse = $request->post($notify_url, array('Content-Type: text/xml'), $req);
} catch (Exception $e) {
common_log(LOG_ERR, "Exception pinging {$notify_url}: " . $e->getMessage());
continue;
}
if (!$httpResponse || mb_strlen($httpResponse->getBody()) == 0) {
common_log(LOG_WARNING, "XML-RPC empty results for ping ({$notify_url}, {$notice->id}) ");
continue;
}
$response = xmlrpc_decode($httpResponse->getBody());
if (is_array($response) && xmlrpc_is_fault($response)) {
common_log(LOG_WARNING, "XML-RPC error for ping ({$notify_url}, {$notice->id}) " . "{$response['faultString']} ({$response['faultCode']})");
} else {
common_log(LOG_INFO, "Ping success for {$notify_url} {$notice->id}");
}
break;
case 'get':
case 'post':
$args = array('name' => $profile->nickname, 'url' => common_local_url('showstream', array('nickname' => $profile->nickname)), 'changesURL' => common_local_url('userrss', array('nickname' => $profile->nickname)));
$fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
if ($type === 'get') {
$result = $fetcher->get($notify_url . '?' . http_build_query($args), array('User-Agent: StatusNet/' . STATUSNET_VERSION));
} else {
$result = $fetcher->post($notify_url, http_build_query($args), array('User-Agent: StatusNet/' . STATUSNET_VERSION));
}
if ($result->status != '200') {
common_log(LOG_WARNING, "Ping error for '{$notify_url}' ({$notice->id}): " . "{$result->body}");
} else {
common_log(LOG_INFO, "Ping success for '{$notify_url}' ({$notice->id}): " . "'{$result->body}'");
}
break;
default:
common_log(LOG_WARNING, 'Unknown notify type for ' . $notify_url . ': ' . $type);
}
}
return true;
}
示例3: Auth_Yadis_Email_getID
/**
* Function for performaing email addresss to ID translation.
*/
function Auth_Yadis_Email_getID($email, $site_name = '')
{
list($user, $domain) = split('@', $email, 2);
$fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
$services = Auth_Yadis_Email_getServices('http://' . $domain, $fetcher);
if (empty($services)) {
$services = Auth_Yadis_Email_getServices('http://www.' . $domain, $fetcher);
if (empty($services)) {
$services = Auth_Yadis_Email_getServices(Auth_Yadis_Default_Email_Mapper, $fetcher);
}
}
return Auth_Yadis_Email_resolve($services, $email);
}
示例4: ping_broadcast_notice
function ping_broadcast_notice($notice)
{
if (!$notice->is_local) {
return true;
}
# Array of servers, URL => type
$notify = common_config('ping', 'notify');
$profile = $notice->getProfile();
$tags = ping_notice_tags($notice);
foreach ($notify as $notify_url => $type) {
switch ($type) {
case 'xmlrpc':
case 'extended':
$req = xmlrpc_encode_request('weblogUpdates.ping', array($profile->nickname, common_local_url('showstream', array('nickname' => $profile->nickname)), common_local_url('shownotice', array('notice' => $notice->id)), common_local_url('userrss', array('nickname' => $profile->nickname)), $tags));
$context = stream_context_create(array('http' => array('method' => "POST", 'header' => "Content-Type: text/xml\r\n" . "User-Agent: Laconica/" . LACONICA_VERSION . "\r\n", 'content' => $req)));
$file = file_get_contents($notify_url, false, $context);
if ($file === false || mb_strlen($file) == 0) {
common_log(LOG_WARNING, "XML-RPC empty results for ping ({$notify_url}, {$notice->id}) ");
continue;
}
$response = xmlrpc_decode($file);
if (xmlrpc_is_fault($response)) {
common_log(LOG_WARNING, "XML-RPC error for ping ({$notify_url}, {$notice->id}) " . "{$response['faultString']} ({$response['faultCode']})");
} else {
common_log(LOG_INFO, "Ping success for {$notify_url} {$notice->id}");
}
break;
case 'get':
case 'post':
$args = array('name' => $profile->nickname, 'url' => common_local_url('showstream', array('nickname' => $profile->nickname)), 'changesURL' => common_local_url('userrss', array('nickname' => $profile->nickname)));
$fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
if ($type === 'get') {
$result = $fetcher->get($notify_url . '?' . http_build_query($args), array('User-Agent: Laconica/' . LACONICA_VERSION));
} else {
$result = $fetcher->post($notify_url, http_build_query($args), array('User-Agent: Laconica/' . LACONICA_VERSION));
}
if ($result->status != '200') {
common_log(LOG_WARNING, "Ping error for '{$notify_url}' ({$notice->id}): " . "{$result->body}");
} else {
common_log(LOG_INFO, "Ping success for '{$notify_url}' ({$notice->id}): " . "'{$result->body}'");
}
break;
default:
common_log(LOG_WARNING, 'Unknown notify type for ' . $notify_url . ': ' . $type);
}
}
return true;
}
示例5: runTest
function runTest()
{
$fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
$y = Auth_Yadis_Yadis::discover($this->input_url, $fetcher);
$this->assertTrue($y !== null);
// Compare parts of returned Yadis object to expected URLs.
$this->assertEquals($this->redir_uri, $y->normalized_uri, "tried {$this->input_url}");
if ($this->xrds_uri) {
$this->assertEquals($this->xrds_uri, $y->xrds_uri);
// Compare contents of actual HTTP GET with that of Yadis
// response.
$f = Auth_Yadis_Yadis::getHTTPFetcher();
$http_response = $f->get($this->xrds_uri);
$this->assertEquals($http_response->body, $y->response_text);
} else {
$this->assertTrue($y->xrds_uri === null);
}
}
示例6: __construct
/**
* Constructor for OMB_Service_Consumer
*
* Initializes an OMB_Service_Consumer object representing the OMB service
* specified by $service_url. Performs a complete service discovery using
* Yadis.
* Throws OMB_UnsupportedServiceException if XRDS file does not specify a
* complete OMB service.
*
* @param string $service_url The URL of the service
* @param string $consumer_url An URL representing the consumer
* @param OMB_Datastore $datastore An instance of a class implementing
* OMB_Datastore
*
* @access public
**/
public function __construct($service_url, $consumer_url, $datastore)
{
$this->url = $service_url;
$this->fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
$this->datastore = $datastore;
$this->oauth_consumer = new OAuthConsumer($consumer_url, '');
$xrds = OMB_Yadis_XRDS::fromYadisURL($service_url, $this->fetcher);
/* Detect our services. This performs a validation as well, since
getService und getXRD throw exceptions on failure. */
$this->services = array();
foreach (array(OAUTH_DISCOVERY => OMB_Helper::$OAUTH_SERVICES, OMB_VERSION => OMB_Helper::$OMB_SERVICES) as $service_root => $targetservices) {
$uris = $xrds->getService($service_root)->getURIs();
$xrd = $xrds->getXRD($uris[0]);
foreach ($targetservices as $targetservice) {
$yadis_service = $xrd->getService($targetservice);
if ($targetservice == OAUTH_ENDPOINT_REQUEST) {
$localid = $yadis_service->getElements('xrd:LocalID');
$this->listener_uri = $yadis_service->parser->content($localid[0]);
}
$uris = $yadis_service->getURIs();
$this->services[$targetservice] = $uris[0];
}
}
}
示例7: list
<html>
<head>
<title>OpenID discovery</title>
</head>
<body>
<h2>OpenID discovery tool</h2>
<p>
Enter an OpenID URL to begin discovery:
</p>
<form>
<input type="text" name="openid_identifier" size="40" />
<input type="submit" value="Begin" />
</form>
<?php
if ($identifier) {
$fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
list($normalized_identifier, $endpoints) = Auth_OpenID_discover($identifier, $fetcher);
?>
<h3>Discovery Results for <?php
echo escape($identifier);
?>
</h3>
<table cellpadding="7" cellspacing="0">
<tbody>
<tr>
<th>Claimed Identifier</th>
<td><?php
echo escape($normalized_identifier);
?>
</td>
示例8: discover
/**
* This should be called statically and will build a Yadis
* instance if the discovery process succeeds. This implements
* Yadis discovery as specified in the Yadis specification.
*
* @param string $uri The URI on which to perform Yadis discovery.
*
* @param array $http_response An array reference where the HTTP
* response object will be stored (see {@link
* Auth_Yadis_HTTPResponse}.
*
* @param Auth_Yadis_HTTPFetcher $fetcher An instance of a
* Auth_Yadis_HTTPFetcher subclass.
*
* @param array $extra_ns_map An array which maps namespace names
* to namespace URIs to be used when parsing the Yadis XRDS
* document.
*
* @param integer $timeout An optional fetcher timeout, in seconds.
*
* @return mixed $obj Either null or an instance of
* Auth_Yadis_Yadis, depending on whether the discovery
* succeeded.
*/
function discover($uri, &$fetcher, $extra_ns_map = null, $timeout = 20)
{
$result = new Auth_Yadis_DiscoveryResult($uri);
$request_uri = $uri;
$headers = array("Accept: " . Auth_Yadis_CONTENT_TYPE . ', text/html; q=0.3, application/xhtml+xml; q=0.5');
if ($fetcher === null) {
$fetcher = Auth_Yadis_Yadis::getHTTPFetcher($timeout);
}
$response = $fetcher->get($uri, $headers);
if (!$response || ($response->status != 200 and $response->status != 206)) {
$result->fail();
return $result;
}
$result->normalized_uri = $response->final_url;
$result->content_type = Auth_Yadis_Yadis::_getHeader($response->headers, array('content-type'));
if ($result->content_type && Auth_Yadis_Yadis::_getContentType($result->content_type) == Auth_Yadis_CONTENT_TYPE) {
$result->xrds_uri = $result->normalized_uri;
} else {
$yadis_location = Auth_Yadis_Yadis::_getHeader($response->headers, array(Auth_Yadis_HEADER_NAME));
if (!$yadis_location) {
$parser = new Auth_Yadis_ParseHTML();
$yadis_location = $parser->getHTTPEquiv($response->body);
}
if ($yadis_location) {
$result->xrds_uri = $yadis_location;
$response = $fetcher->get($yadis_location);
if (!$response || ($response->status != 200 and $response->status != 206)) {
$result->fail();
return $result;
}
$result->content_type = Auth_Yadis_Yadis::_getHeader($response->headers, array('content-type'));
}
}
$result->response_text = $response->body;
return $result;
}
示例9: Auth_OpenID_GenericConsumer
/**
* This method initializes a new {@link Auth_OpenID_Consumer}
* instance to access the library.
*
* @param Auth_OpenID_OpenIDStore $store This must be an object
* that implements the interface in {@link Auth_OpenID_OpenIDStore}.
* Several concrete implementations are provided, to cover most common use
* cases. For stores backed by MySQL, PostgreSQL, or SQLite, see
* the {@link Auth_OpenID_SQLStore} class and its sublcasses. For a
* filesystem-backed store, see the {@link Auth_OpenID_FileStore} module.
* As a last resort, if it isn't possible for the server to store
* state at all, an instance of {@link Auth_OpenID_DumbStore} can be used.
*
* @param bool $immediate This is an optional boolean value. It
* controls whether the library uses immediate mode, as explained
* in the module description. The default value is False, which
* disables immediate mode.
*/
function Auth_OpenID_GenericConsumer($store)
{
$this->store = $store;
$this->negotiator = Auth_OpenID_getDefaultNegotiator();
$this->_use_assocs = is_null($this->store) ? false : true;
$this->fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
$this->session_types = Auth_OpenID_getAvailableSessionTypes();
}
示例10: detect_fetcher
function detect_fetcher($r, &$out)
{
$out .= $r->h2('HTTP Fetching');
$result = @(include 'Auth/Yadis/Yadis.php');
if (!$result) {
$out .= $r->p('Yadis code unavailable; could not test fetcher support.');
return false;
}
if (Auth_Yadis_Yadis::curlPresent()) {
$out .= $r->p('This PHP installation has support for libcurl. Good.');
} else {
$out .= $r->p('This PHP installation does not have support for ' . 'libcurl. CURL is not required but is recommended. ' . 'The OpenID library will use an fsockopen()-based fetcher.');
$lnk = $r->link('http://us3.php.net/manual/en/ref.curl.php');
$out .= $r->p('See ' . $lnk . ' about enabling the libcurl support ' . 'for PHP.');
}
$ok = true;
$fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
$fetch_url = 'http://www.openidenabled.com/resources/php-fetch-test';
$expected_url = $fetch_url . '.txt';
$result = $fetcher->get($fetch_url);
if (isset($result)) {
$parts = array('An HTTP request was completed.');
// list ($code, $url, $data) = $result;
if ($result->status != '200') {
$ok = false;
$parts[] = $r->b(sprintf('Got %s instead of the expected HTTP status code ' . '(200).', $result->status));
}
$url = $result->final_url;
if ($url != $expected_url) {
$ok = false;
if ($url == $fetch_url) {
$msg = 'The redirected URL was not returned.';
} else {
$msg = 'An unexpected URL was returned: <' . $url . '>.';
}
$parts[] = $r->b($msg);
}
$data = $result->body;
if ($data != 'Hello World!') {
$ok = false;
$parts[] = $r->b('Unexpected data was returned.');
}
$out .= $r->p(implode(' ', $parts));
} else {
$ok = false;
$out .= $r->p('Fetching URL ' . $lnk . ' failed!');
}
if ($fetcher->supportsSSL()) {
$out .= $r->p('Your PHP installation appears to support SSL, so it ' . 'will be able to process HTTPS identity URLs and server URLs.');
} else {
$out .= $r->p('Your PHP installation does not support SSL, so it ' . 'will NOT be able to process HTTPS identity URLs and server URLs.');
}
return $ok;
}
示例11: Auth_OpenID_GenericConsumer
/**
* This method initializes a new {@link Auth_OpenID_Consumer}
* instance to access the library.
*
* @param Auth_OpenID_Store_OpenIDStore $store This must be an object
* that implements the interface in {@link Auth_OpenID_Store_OpenIDStore}.
* Several concrete implementations are provided, to cover most common use
* cases. For stores backed by MySQL, PostgreSQL, or SQLite, see
* the {@link Auth_OpenID_Store_SQLStore} class and its sublcasses. For a
* filesystem-backed store, see the {@link Auth_OpenID_Store_FileStore} module.
* As a last resort, if it isn't possible for the server to store
* state at all, an instance of {@link Auth_OpenID_Store_DumbStore} can be used.
*
* @param bool $immediate This is an optional boolean value. It
* controls whether the library uses immediate mode, as explained
* in the module description. The default value is False, which
* disables immediate mode.
*/
function Auth_OpenID_GenericConsumer($store)
{
$this->store = $store;
$this->negotiator = Auth_OpenID_getDefaultNegotiator();
$this->_use_assocs = true;
if (is_null($this->store) || is_a($this->store, 'Auth_OpenID_Store_DumbStore')) {
$this->_use_assocs = false;
}
$this->fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
$this->session_types = Auth_OpenID_getAvailableSessionTypes();
}
示例12: omb_update_profile
function omb_update_profile($profile, $remote_profile, $subscription)
{
$user = User::staticGet($profile->id);
$con = omb_oauth_consumer();
$token = new OAuthToken($subscription->token, $subscription->secret);
$url = $remote_profile->updateprofileurl;
$parsed = parse_url($url);
$params = array();
parse_str($parsed['query'], $params);
$req = OAuthRequest::from_consumer_and_token($con, $token, "POST", $url, $params);
$req->set_parameter('omb_version', OMB_VERSION_01);
$req->set_parameter('omb_listenee', $user->uri);
$req->set_parameter('omb_listenee_profile', common_profile_url($profile->nickname));
$req->set_parameter('omb_listenee_nickname', $profile->nickname);
# We use blanks to force emptying any existing values in these optional fields
$req->set_parameter('omb_listenee_fullname', $profile->fullname ? $profile->fullname : '');
$req->set_parameter('omb_listenee_homepage', $profile->homepage ? $profile->homepage : '');
$req->set_parameter('omb_listenee_bio', $profile->bio ? $profile->bio : '');
$req->set_parameter('omb_listenee_location', $profile->location ? $profile->location : '');
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
$req->set_parameter('omb_listenee_avatar', $avatar ? $avatar->url : '');
$req->sign_request(omb_hmac_sha1(), $con, $token);
# We re-use this tool's fetcher, since it's pretty good
$fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
common_debug('request URL = ' . $req->get_normalized_http_url(), __FILE__);
common_debug('postdata = ' . $req->to_postdata(), __FILE__);
$result = $fetcher->post($req->get_normalized_http_url(), $req->to_postdata(), array('User-Agent: Laconica/' . LACONICA_VERSION));
common_debug('Got HTTP result "' . print_r($result, true) . '"', __FILE__);
if (empty($result) || !$result) {
common_debug("Unable to contact " . $req->get_normalized_http_url());
} else {
if ($result->status == 403) {
# not authorized, don't send again
common_debug('403 result, deleting subscription', __FILE__);
$subscription->delete();
return false;
} else {
if ($result->status != 200) {
common_debug('Error status ' . $result->status, __FILE__);
return false;
} else {
# success!
parse_str($result->body, $return);
if (isset($return['omb_version']) && $return['omb_version'] === OMB_VERSION_01) {
return true;
} else {
return false;
}
}
}
}
}
示例13: access_token
function access_token($omb)
{
common_debug('starting request for access token', __FILE__);
$con = omb_oauth_consumer();
$tok = new OAuthToken($omb['token'], $omb['secret']);
common_debug('using request token "' . $tok . '"', __FILE__);
$url = $omb['access_token_url'];
common_debug('using access token url "' . $url . '"', __FILE__);
# XXX: Is this the right thing to do? Strip off GET params and make them
# POST params? Seems wrong to me.
$parsed = parse_url($url);
$params = array();
parse_str($parsed['query'], $params);
$req = OAuthRequest::from_consumer_and_token($con, $tok, "POST", $url, $params);
$req->set_parameter('omb_version', OMB_VERSION_01);
# XXX: test to see if endpoint accepts this signature method
$req->sign_request(omb_hmac_sha1(), $con, $tok);
# We re-use this tool's fetcher, since it's pretty good
common_debug('posting to access token url "' . $req->get_normalized_http_url() . '"', __FILE__);
common_debug('posting request data "' . $req->to_postdata() . '"', __FILE__);
$fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
$result = $fetcher->post($req->get_normalized_http_url(), $req->to_postdata(), array('User-Agent: Laconica/' . LACONICA_VERSION));
common_debug('got result: "' . print_r($result, true) . '"', __FILE__);
if ($result->status != 200) {
return null;
}
parse_str($result->body, $return);
return array($return['oauth_token'], $return['oauth_token_secret']);
}
示例14: __construct
/**
* This method initializes a new {@link Auth_OpenID_Consumer}
* instance to access the library.
*
* @param Auth_OpenID_OpenIDStore $store This must be an object
* that implements the interface in {@link Auth_OpenID_OpenIDStore}.
* Several concrete implementations are provided, to cover most common use
* cases. For stores backed by MySQL, PostgreSQL, or SQLite, see
* the {@link Auth_OpenID_SQLStore} class and its sublcasses. For a
* filesystem-backed store, see the {@link Auth_OpenID_FileStore} module.
* As a last resort, if it isn't possible for the server to store
* state at all, an instance of {@link Auth_OpenID_DumbStore} can be used.
*
* @param bool $immediate This is an optional boolean value. It
* controls whether the library uses immediate mode, as explained
* in the module description. The default value is False, which
* disables immediate mode.
*/
function __construct(&$store)
{
$this->store =& $store;
$this->negotiator =& Auth_OpenID_getDefaultNegotiator();
$this->_use_assocs = $this->store ? true : false;
$this->fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
$this->session_types = Auth_OpenID_getAvailableSessionTypes();
}
示例15: __construct
/**
* This method initializes a new {@link Auth_OpenID_Consumer}
* instance to access the library.
*
* @param Auth_OpenID_OpenIDStore $store This must be an object
* that implements the interface in {@link Auth_OpenID_OpenIDStore}.
* Several concrete implementations are provided, to cover most common use
* cases. For stores backed by MySQL, PostgreSQL, or SQLite, see
* the {@link Auth_OpenID_SQLStore} class and its sublcasses. For a
* filesystem-backed store, see the {@link Auth_OpenID_FileStore} module.
* As a last resort, if it isn't possible for the server to store
* state at all, an instance of {@link Auth_OpenID_DumbStore} can be used.
*
* @param bool $immediate This is an optional boolean value. It
* controls whether the library uses immediate mode, as explained
* in the module description. The default value is False, which
* disables immediate mode.
*/
public function __construct($store)
{
$this->store = $store;
$this->negotiator = Auth_OpenID_getDefaultNegotiator();
$this->_use_assocs = is_null($this->store) ? false : true;
if (get_class($this->store) == "Auth_OpenID_DumbStore") {
$this->_use_assocs = false;
}
$this->fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
$this->session_types = Auth_OpenID_getAvailableSessionTypes();
}