本文整理汇总了PHP中Varien_Http_Adapter_Curl::addOption方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Http_Adapter_Curl::addOption方法的具体用法?PHP Varien_Http_Adapter_Curl::addOption怎么用?PHP Varien_Http_Adapter_Curl::addOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Http_Adapter_Curl
的用法示例。
在下文中一共展示了Varien_Http_Adapter_Curl::addOption方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeHttpPostRequest
/**
* Send a HTTP Post request
*
* @param string $url
* @param array $data = array
* @return false|string
*/
public function makeHttpPostRequest($url, array $data = array())
{
if (!$this->hasValidCurlMethods()) {
foreach ($data as $key => $value) {
$data[$key] = urlencode($key) . '=' . urlencode($value);
}
$body = implode('&', $data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($data));
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_USERAGENT, self::CURL_USERAGENT);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if (strpos($url, 'https://') !== false) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}
$response = curl_exec($ch);
if (curl_errno($ch) || curl_error($ch)) {
throw new Exception(Mage::helper('wordpress')->__('CURL (%s): %s', curl_errno($ch), curl_error($ch)));
}
curl_close($ch);
return $response;
}
$curl = new Varien_Http_Adapter_Curl();
$curl->setConfig(array('verifypeer' => strpos($url, 'https://') !== false, 'header' => true, 'timeout' => 15, 'referrer' => Mage::helper('wordpress')->getBaseUrl('wp-login.php')));
$curl->addOption(CURLOPT_FOLLOWLOCATION, false);
$curl->addOption(CURLOPT_USERAGENT, self::CURL_USERAGENT);
$curl->addOption(CURLOPT_REFERER, true);
$curl->write(Zend_Http_Client::POST, $url, '1.1', array('Expect:'), $data);
$response = $curl->read();
if ($curl->getErrno() || $curl->getError()) {
throw new Exception(Mage::helper('wordpress')->__('CURL (%s): %s', $curl->getErrno(), $curl->getError()));
}
$curl->close();
return $response;
}
示例2: indexAction
//.........这里部分代码省略.........
$supportUrlName = $names[3];
$firstnameName = $names[6];
$lastnameName = $names[7];
$emailName = $names[8];
$phoneName = $names[9];
$tradeRepFirstnameName = $names[12];
$tradeRepLastnameName = $names[13];
$addressLine1Name = $names[14];
$addressLine2Name = $names[15];
$cityName = $names[16];
$postalCodeName = $names[17];
$contactEmailName = $names[19];
$contactPhoneName = $names[20];
//description
$regex_pattern = "/<textarea onblur(.*?)name=\"(.*?)\"><\\/textarea>/";
preg_match($regex_pattern, $content, $match);
$descriptionName = $match[2];
//country
$regex_pattern = "/<select id=\"country-popup\" name=\"(.*?)\">/";
preg_match($regex_pattern, $content, $match);
$countryName = $match[1];
//rate Content Descriptions
$regex_pattern = "/<input class=\"br-1\" id=\"rank-1\" type=\"radio\" value=\"(.*?)\" name=\"(.*?)\" \\/>/";
preg_match_all($regex_pattern, $content, $matches);
$str = '';
$i = 0;
foreach ($matches[2] as $ratingName) {
$str .= $ratingName . '=' . $matches[1][$i++] . '&';
}
$str = trim($str, '&');
$regex_pattern = "/name = \"uploadSessionID\" value=\"(.*?)\">/";
preg_match($regex_pattern, $content, $match);
$sessionId = $match[1];
$http->addOption(CURLOPT_BINARYTRANSFER, true);
$http->addOption(CURLOPT_CUSTOMREQUEST, "POST");
$http->addOption(CURLOPT_UPLOAD, 1);
//upload images
$uploadUrl = 'https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wa/LCUploader/upload?uploadKey=';
$uploadKeys = array('largeAppIcon', '35InchRetinaDisplayScreenshots', 'iPhone5');
$i = 0;
foreach ($images as $imageName) {
$image = fopen($imageName, "rb");
$http->addOption(CURLOPT_INFILE, $image);
$http->addOption(CURLOPT_INFILESIZE, filesize($imageName));
$header = array('Content-Type: image/png', 'x-original-filename: ' . $imageName, 'x-uploadKey: ' . $uploadKeys[$i], 'x-uploadSessionID: ' . $sessionId);
//print_r($header);
$http->write(Zend_Http_Client::POST, $uploadUrl . $uploadKeys[$i], '1.1', $header);
$content1 = $http->read();
//print_r($content1);
$header = array('X-Prototype-Version:1.7', 'X-Requested-With:XMLHttpRequest', 'Content-type:application/x-www-form-urlencoded; charset=UTF-8', 'Referer:' . $url);
$regex_pattern = "/'{$uploadKeys[$i]}', statusURL: '(.*?)'/";
preg_match($regex_pattern, $content, $match);
$afterUploadUrl = 'https://itunesconnect.apple.com' . $match[1];
//echo $afterUploadUrl;
$http->write(Zend_Http_Client::POST, $afterUploadUrl, '1.1', $header);
$content1 = $http->read();
$i++;
}
//submit info
$body = $versionName . '=' . $version . '&' . $copyrightName . '=Simicart&' . $primaryCategoryName . '=1&' . $keywordsName . '=' . $keywords . '&' . $descriptionName . '=' . $description . '&' . $supportUrlName . '=' . $websiteUrl . '&' . $firstnameName . '=' . $contactInfo[0] . '&' . $lastnameName . '=' . $contactInfo[1] . '&' . $emailName . '=' . $contactInfo[2] . '&' . $phoneName . '=' . $contactInfo[3] . '&' . $addressLine1Name . '=' . 'Lot 15/C16, Dinh Cong Living Urban,' . '&' . $addressLine2Name . '=' . 'Dinh Cong ward, Hoang Mai district' . '&' . $cityName . '=' . 'hanoi' . '&' . $postalCodeName . '=' . '10000' . '&' . $countryName . '=' . '252' . '&' . $str;
//echo $url;
$http->addOption(CURLOPT_UPLOAD, false);
$http->write(Zend_Http_Client::POST, $url, '1.1', NULL, $body);
$content = $http->read();
$pos1 = strpos($content, 'woa/wo/');
$pos2 = strpos($content, 'x-apple-application-instance');
示例3: makeHttpPostRequest
/**
* Send a HTTP Post request
*
* @param string $url
* @param array $data = array
* @return false|string
*/
public function makeHttpPostRequest($url, array $data = array())
{
if (!$this->hasValidCurlMethods()) {
return $this->_makeLegacyHttpPostRequest($url, $data);
}
$curl = new Varien_Http_Adapter_Curl();
$curl->setConfig(array('verifypeer' => strpos($url, 'https://') !== false, 'header' => true, 'timeout' => 15, 'referrer' => Mage::helper('wordpress')->getBaseUrl('wp-login.php')));
$curl->addOption(CURLOPT_FOLLOWLOCATION, false);
$curl->addOption(CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
$curl->write(Zend_Http_Client::POST, $url, '1.1', array(), $data);
$response = $curl->read();
if ($curl->getErrno() || $curl->getError()) {
throw new Exception(Mage::helper('wordpress')->__('CURL (%s): %s', $curl->getErrno(), $curl->getError()));
}
$curl->close();
return $response;
}
示例4: submitApp
//.........这里部分代码省略.........
$supportUrlName = $names[3];
$firstnameName = $names[6];
$lastnameName = $names[7];
$emailName = $names[8];
$phoneName = $names[9];
$tradeRepFirstnameName = $names[12];
$tradeRepLastnameName = $names[13];
$addressLine1Name = $names[14];
$addressLine2Name = $names[15];
$cityName = $names[16];
$postalCodeName = $names[17];
$contactEmailName = $names[19];
$contactPhoneName = $names[20];
//description
$regex_pattern = "/<textarea onblur(.*?)name=\"(.*?)\"><\\/textarea>/";
preg_match($regex_pattern, $content, $match);
$descriptionName = $match[2];
//country
$regex_pattern = "/<select id=\"country-popup\" name=\"(.*?)\">/";
preg_match($regex_pattern, $content, $match);
$countryName = $match[1];
//rate Content Descriptions
$regex_pattern = "/<input class=\"br-1\" id=\"rank-1\" type=\"radio\" value=\"(.*?)\" name=\"(.*?)\" \\/>/";
preg_match_all($regex_pattern, $content, $matches);
$str = '';
$i = 0;
foreach ($matches[2] as $ratingName) {
$str .= $ratingName . '=' . $matches[1][$i++] . '&';
}
$str = trim($str, '&');
$regex_pattern = "/name = \"uploadSessionID\" value=\"(.*?)\">/";
preg_match($regex_pattern, $content, $match);
$sessionId = $match[1];
$http->addOption(CURLOPT_BINARYTRANSFER, true);
$http->addOption(CURLOPT_CUSTOMREQUEST, "POST");
$http->addOption(CURLOPT_UPLOAD, 1);
//upload images
$uploadUrl = 'https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wa/LCUploader/upload?uploadKey=';
$uploadKeys = array('largeAppIcon', '35InchRetinaDisplayScreenshots', 'iPhone5');
$i = 0;
foreach ($images as $imageName) {
$image = fopen($imageName, "rb");
$http->addOption(CURLOPT_INFILE, $image);
$http->addOption(CURLOPT_INFILESIZE, filesize($imageName));
$header = array('Content-Type: image/png', 'x-original-filename: ' . $imageName, 'x-uploadKey: ' . $uploadKeys[$i], 'x-uploadSessionID: ' . $sessionId);
//print_r($header);
$http->write(Zend_Http_Client::POST, $uploadUrl . $uploadKeys[$i], '1.1', $header);
$content1 = $http->read();
//print_r($content1);
$header = array('X-Prototype-Version:1.7', 'X-Requested-With:XMLHttpRequest', 'Content-type:application/x-www-form-urlencoded; charset=UTF-8', 'Referer:' . $url);
$regex_pattern = "/'{$uploadKeys[$i]}', statusURL: '(.*?)'/";
preg_match($regex_pattern, $content, $match);
$afterUploadUrl = 'https://itunesconnect.apple.com' . $match[1];
//echo $afterUploadUrl;
$http->write(Zend_Http_Client::POST, $afterUploadUrl, '1.1', $header);
$content1 = $http->read();
$i++;
}
//submit info
$body = $versionName . '=' . $version . '&' . $copyrightName . '=Simicart&' . $primaryCategoryName . '=1&' . $keywordsName . '=' . $keywords . '&' . $descriptionName . '=' . $description . '&' . $supportUrlName . '=' . $websiteUrl . '&' . $firstnameName . '=' . $contactInfo[0] . '&' . $lastnameName . '=' . $contactInfo[1] . '&' . $emailName . '=' . $contactInfo[2] . '&' . $phoneName . '=' . $contactInfo[3] . '&' . $addressLine1Name . '=' . 'Lot 15/C16, Dinh Cong Living Urban,' . '&' . $addressLine2Name . '=' . 'Dinh Cong ward, Hoang Mai district' . '&' . $cityName . '=' . 'hanoi' . '&' . $postalCodeName . '=' . '10000' . '&' . $countryName . '=' . '252' . '&' . $str;
//echo $url;
$http->addOption(CURLOPT_UPLOAD, false);
$http->write(Zend_Http_Client::POST, $url, '1.1', NULL, $body);
$content = $http->read();
$pos1 = strpos($content, 'woa/wo/');
$pos2 = strpos($content, 'x-apple-application-instance');