本文整理匯總了PHP中nzedb\utility\Misc::curlSslContextOptions方法的典型用法代碼示例。如果您正苦於以下問題:PHP Misc::curlSslContextOptions方法的具體用法?PHP Misc::curlSslContextOptions怎麽用?PHP Misc::curlSslContextOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nzedb\utility\Misc
的用法示例。
在下文中一共展示了Misc::curlSslContextOptions方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: aws_signed_request
/**
* @param $region
* @param $params
* @param $public_key
* @param $private_key
* @param string $associate_tag
*
* @return bool|SimpleXMLElement|string
*/
private function aws_signed_request($region, $params, $public_key, $private_key, $associate_tag = "")
{
if ($public_key !== "" && $private_key !== "" && $associate_tag !== "") {
$method = "GET";
// Must be in small case.
$host = "ecs.amazonaws." . $region;
$uri = "/onca/xml";
$params["Service"] = "AWSECommerceService";
$params["AWSAccessKeyId"] = $public_key;
$params["AssociateTag"] = $associate_tag;
$params["Timestamp"] = gmdate("Y-m-d\\TH:i:s\\Z");
$params["Version"] = "2009-03-31";
/* The params need to be sorted by the key, as Amazon does this at
their end and then generates the hash of the same. If the params
are not in order then the generated hash will be different thus
failing the authetication process.
*/
ksort($params);
$canonicalized_query = array();
foreach ($params as $param => $value) {
$param = str_replace("%7E", "~", rawurlencode($param));
$value = str_replace("%7E", "~", rawurlencode($value));
$canonicalized_query[] = $param . "=" . $value;
}
$canonicalized_query = implode("&", $canonicalized_query);
$string_to_sign = $method . "\n" . $host . "\n" . $uri . "\n" . $canonicalized_query;
/* Calculate the signature using HMAC with SHA256 and base64-encoding.
* The 'hash_hmac' function is only available from PHP 5 >= 5.1.2.
*/
$signature = base64_encode(hash_hmac("sha256", $string_to_sign, $private_key, True));
// Encode the signature for the request.
$signature = str_replace("%7E", "~", rawurlencode($signature));
// Create request.
$request = "http://" . $host . $uri . "?" . $canonicalized_query . "&Signature=" . $signature;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt_array($ch, Misc::curlSslContextOptions());
$xml_response = curl_exec($ch);
if ($xml_response === False) {
return False;
} else {
// Parse XML.
$parsed_xml = @simplexml_load_string($xml_response);
return $parsed_xml === False ? False : $parsed_xml;
}
} else {
return "missingkey";
}
}
示例2: getUrl
/**
* Gets Raw Html
*
* @param string $fetchURL
* @param bool $usePost
*
* @return bool
*/
private function getUrl($fetchURL, $usePost = false)
{
if (isset($fetchURL)) {
$this->_ch = curl_init($fetchURL);
}
if ($usePost === true) {
curl_setopt($this->_ch, CURLOPT_POST, 1);
curl_setopt($this->_ch, CURLOPT_POSTFIELDS, $this->_postParams);
}
curl_setopt($this->_ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($this->_ch, CURLOPT_HEADER, 0);
curl_setopt($this->_ch, CURLOPT_VERBOSE, 0);
curl_setopt($this->_ch, CURLOPT_USERAGENT, "Firefox/2.0.0.1");
curl_setopt($this->_ch, CURLOPT_FAILONERROR, 1);
if (isset($this->cookie)) {
curl_setopt($this->_ch, CURLOPT_COOKIEJAR, $this->cookie);
curl_setopt($this->_ch, CURLOPT_COOKIEFILE, $this->cookie);
}
curl_setopt_array($this->_ch, Misc::curlSslContextOptions());
$this->_response = curl_exec($this->_ch);
if (!$this->_response) {
curl_close($this->_ch);
return false;
}
curl_close($this->_ch);
$this->_html->load($this->_response);
return true;
}
示例3: getUrl
/**
* Gets raw html content using adeurl and any trailing url.
*
* @param string $trailing - required
*
* @return bool - true if page has content
*/
private function getUrl($trailing = "")
{
if (!empty($trailing)) {
$this->_ch = curl_init(self::ADE . $trailing);
}
if (!empty($this->directLink)) {
$this->_ch = curl_init($this->directLink);
$this->directLink = "";
}
curl_setopt($this->_ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($this->_ch, CURLOPT_HEADER, 0);
curl_setopt($this->_ch, CURLOPT_VERBOSE, 0);
curl_setopt($this->_ch, CURLOPT_USERAGENT, "Firefox/2.0.0.1");
curl_setopt($this->_ch, CURLOPT_FAILONERROR, 1);
curl_setopt_array($this->_ch, Misc::curlSslContextOptions());
$this->_response = curl_exec($this->_ch);
if (!$this->_response) {
curl_close($this->_ch);
return false;
}
curl_close($this->_ch);
return true;
}
示例4: getUrl
/**
* Get Raw html of webpage
*
* @param bool $usepost
*
* @return bool
*/
private function getUrl($usepost = false)
{
if (isset($this->_trailUrl)) {
$ch = curl_init(self::ADMURL . $this->_trailUrl);
} else {
$ch = curl_init(self::IF18);
}
if ($usepost === true) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_postParams);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Firefox/2.0.0.1");
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
if (isset($this->cookie)) {
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie);
}
curl_setopt_array($ch, Misc::curlSslContextOptions());
$this->_response = curl_exec($ch);
if (!$this->_response) {
curl_close($ch);
return false;
}
curl_close($ch);
$this->_html->load($this->_response);
return true;
}
示例5: getUrl
private function getUrl()
{
if ($this->_doSearch === true) {
$ch = curl_init(self::IAFDSEARCHURL . urlencode($this->searchTerm));
} else {
if (empty($this->_getRedirect)) {
$ch = curl_init(self::IAFDURL);
} else {
$ch = curl_init($this->_getRedirect);
}
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Firefox/2.0.0.1");
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
if (isset($this->cookie)) {
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie);
}
curl_setopt_array($ch, Misc::curlSslContextOptions());
$this->_response = curl_exec($ch);
if (!empty($this->_getRedirect)) {
$this->_getRedirect = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
curl_close($ch);
return $this->_getRedirect;
}
if (!$this->_response) {
curl_close($ch);
return false;
}
curl_close($ch);
if ($this->_doSearch === true) {
$this->_html->load($this->_response);
$this->_doSearch = false;
}
return true;
}