本文整理汇总了PHP中Zend_Http_Client类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Client类的具体用法?PHP Zend_Http_Client怎么用?PHP Zend_Http_Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Http_Client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* 決済開始
* @args $args['cardnumber'] ハイフンなしのカード番号
* @args $args['expyy'] 年(2桁)
* @args $args['expmm'] 月(2桁)
* @args $args['telno'] ハイフンなしの電話番号
* @args $args['email'] メールアドレス
* @args $args['sendid'] 注文ID
* @args $args['username'] スペースなしのユーザー名(英字)
* @args $args['money'] 決済金額(総額)
* @args $args['div'] 分割数(01/03/05/06/10)
*/
public static function execute($args)
{
$config = Zend_Registry::get('config');
$params['clientip'] = $config->zeus->clientip;
$params['cardnumber'] = $args['cardnumber'];
$params['expyy'] = $args['expyy'];
$params['expmm'] = $args['expmm'];
$params['telno'] = $args['telno'];
$params['email'] = $args['email'];
$params['sendid'] = $args['sendid'];
$params['username'] = $args['username'];
$params['money'] = $args['money'];
$params['sendpoint'] = 'eccube';
$params['send'] = 'mall';
$params['pubsec'] = '';
$params['div'] = $args['div'];
// 0円のときは決済しない
if (!$args['money']) {
return false;
}
// 決済開始
$client = new Zend_Http_Client($config->zeus->api_url);
$client->setParameterPost($params);
$response = $client->request('POST');
// 結果の判定
if ($response->getBody() === 'Success_order') {
return true;
} else {
return false;
}
}
示例2: icsAction
public function icsAction()
{
$this->api_user = Mage::getModel('core/variable')->setStoreId(Mage::app()->getStore()->getId())->loadByCode('pmt_api_user')->getValue('text');
$this->api_password = Mage::getModel('core/variable')->setStoreId(Mage::app()->getStore()->getId())->loadByCode('pmt_api_password')->getValue('text');
// get prescription id
$prescriptionRepeatId = Mage::app()->getRequest()->getParam('id');
$customer = Mage::getSingleton('customer/session')->getCustomer();
$client = new Zend_Http_Client($this->api_get_prescripton_url . $prescriptionRepeatId);
$params = ['pmt_user_id' => $customer->getId(), 'prescription_repeat_id' => $prescriptionRepeatId];
// set some parameters
$client->setParameterPost($params);
$client->setAuth($this->api_user, $this->api_password, \Zend_Http_Client::AUTH_BASIC);
// POST request
$result = $client->request(Zend_Http_Client::POST);
// decode response
$jsonData = json_decode($result->getBody());
// var_dump($prescriptionRepeatId . $customer->getId());
// var_dump($result);
// exit();
if (!$jsonData->status == 'success') {
// create error message, before redirecting
// redirect to prescriptions page
$this->redirectDashboard();
}
$this->loadLayout();
$block = $this->getLayout()->getBlock('prescriptions_ics');
$block->assign(['repeat' => $jsonData->data->repeats[0], 'product' => $jsonData->data->prescription]);
$this->renderLayout();
}
示例3: studentAction
/**
* The default action - show the home page
*/
public function studentAction()
{
$this->_helper->viewRenderer->setNoRender(false);
$request = $this->getRequest();
$department = $request->getParam('department_id');
$degree = $request->getParam('degree_id');
$batch = $request->getParam('batch');
if (isset($degree) and isset($department) and isset($batch)) {
$client = new Zend_Http_Client('http://' . CORE_SERVER . '/batch/getbatchstudent' . "?department_id={$department}" . "°ree_id={$degree}" . "&batch_id={$batch}");
$client->setCookie('PHPSESSID', $_COOKIE['PHPSESSID']);
$response = $client->request();
if ($response->isError()) {
$remoteErr = 'REMOTE ERROR: (' . $response->getStatus() . ') ' . $response->getHeader('Message');
throw new Zend_Exception($remoteErr, Zend_Log::ERR);
} else {
$jsonContent = $response->getBody($response);
$students = Zend_Json::decode($jsonContent);
$this->_helper->logger($jsonContent);
$this->view->assign('students', $students);
$this->view->assign('department', $department);
$this->view->assign('degree', $degree);
$this->view->assign('batch', $batch);
}
}
}
示例4: collectRates
/**
* @param Mage_Shipping_Model_Rate_Request $request
* @return Mage_Shipping_Model_Rate_Result
*/
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
/** @var Mage_Shipping_Model_Rate_Result $result */
$result = Mage::getModel('shipping/rate_result');
$totalWeight = 0;
foreach ($request->getAllItems() as $item) {
$totalWeight += $item->getWeight() * $item->getQty();
}
/** @var string $hostname */
$hostname = $this->getConfigData('hostname');
/** @var string $port */
$port = $this->getConfigData('port');
try {
$client = new Zend_Http_Client();
$response = $client->setUri("http://{$hostname}:{$port}/")->setRawData(json_encode(['totalWeight' => $totalWeight]))->setEncType('application/json')->request('POST');
switch ($response->getStatus()) {
case 200:
$responseBody = json_decode($response->getBody());
$result->append($this->_getShippingMethod($responseBody->rate));
break;
case 500:
// Handle 500 Error
break;
default:
}
} catch (Exception $e) {
var_dump($e);
}
return $result;
}
示例5: validate
public function validate($username, $password)
{
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Options: ' . print_r($this->_options, true));
}
$url = isset($this->_options['url']) ? $this->_options['url'] : 'https://localhost/validate/check';
$adapter = new Zend_Http_Client_Adapter_Socket();
$adapter->setStreamContext($this->_options = array('ssl' => array('verify_peer' => isset($this->_options['ignorePeerName']) ? false : true, 'allow_self_signed' => isset($this->_options['allowSelfSigned']) ? true : false)));
$client = new Zend_Http_Client($url, array('maxredirects' => 0, 'timeout' => 30));
$client->setAdapter($adapter);
$params = array('user' => $username, 'pass' => $password);
$client->setParameterPost($params);
try {
$response = $client->request(Zend_Http_Client::POST);
} catch (Zend_Http_Client_Adapter_Exception $zhcae) {
Tinebase_Exception::log($zhcae);
return Tinebase_Auth::FAILURE;
}
$body = $response->getBody();
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Request: ' . $client->getLastRequest());
}
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Response: ' . $body);
}
if ($response->getStatus() !== 200) {
return Tinebase_Auth::FAILURE;
}
$result = Tinebase_Helper::jsonDecode($body);
if (isset($result['result']) && $result['result']['status'] === true && $result['result']['value'] === true) {
return Tinebase_Auth::SUCCESS;
} else {
return Tinebase_Auth::FAILURE;
}
}
示例6: responseAction
public function responseAction()
{
// Get User Configuration
$epayphId = Mage::getStoreConfig('payment/epayphPaymentModule/epayphId');
$apiKey = Mage::getStoreConfig('payment/epayphPaymentModule/epayphApiKey');
$apiSecret = Mage::getStoreConfig('payment/epayphPaymentModule/epayphApiSecret');
$url = 'https://epay.ph/api/validateIPN';
$json = json_encode($_POST);
$client = new Zend_Http_Client($url);
$client->setHeaders(array('Accept: application/json'));
$_POST['cmd'] = '_notify-validate';
$client->setParameterPost($_POST);
$request = $client->request('POST');
if ($request->getBody() == '{"return":"VERIFIED"}') {
$order = Mage::getModel('sales/order');
$order->loadByIncrementId($_POST['invoice']);
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, "Epay.ph Gateway informed us: the payment's Transaction ID is {$_POST['txn_id']}");
$order->sendNewOrderEmail();
$order->setEmailSent(true);
$order->save();
Mage::getSingleton('checkout/session')->unsQuoteId();
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure' => true));
} else {
$this->cancelAction(FALSE, 'Epay.ph signature did not validate');
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure' => true));
}
}
示例7: getPluginList
protected function getPluginList()
{
$list = array();
$config = null;
if ($proxy = parse_url(sfConfig::get('op_http_proxy'))) {
$config = array('adapter' => 'Zend_Http_Client_Adapter_Proxy');
if (isset($proxy['host'])) {
$config['proxy_host'] = $proxy['host'];
}
if (isset($proxy['port'])) {
$config['proxy_port'] = $proxy['port'];
}
if (isset($proxy['user'])) {
$config['proxy_user'] = $proxy['user'];
}
if (isset($proxy['pass'])) {
$config['proxy_pass'] = $proxy['pass'];
}
}
try {
$client = new Zend_Http_Client('http://' . opPluginManager::OPENPNE_PLUGIN_CHANNEL . '/packages/' . OPENPNE_VERSION . '.yml', $config);
$response = $client->request();
if ($response->isSuccessful()) {
$list = sfYaml::load($response->getBody());
$list = $this->applyLocalPluginList($list);
} else {
$str = "Failed to download plugin list.";
$this->logBlock($str, 'ERROR');
}
} catch (Zend_Http_Client_Adapter_Exception $e) {
$str = "Failed to download plugins list.";
$this->logBlock($str, 'ERROR');
}
return $list;
}
示例8: validate
/**
* Validate the license information
*
* @param string $userId
* @param array $spMetadata
* @param array $idpMetadata
* @return string
*/
public function validate($userId, array $spMetadata, array $idpMetadata)
{
if (!$this->_active) {
return EngineBlock_LicenseEngine_ValidationManager::LICENSE_UNKNOWN;
}
$client = new Zend_Http_Client($this->_url);
$client->setConfig(array('timeout' => 15));
try {
$client->setHeaders(Zend_Http_Client::CONTENT_TYPE, 'application/json; charset=utf-8')->setParameterGet('userId', urlencode($userId))->setParameterGet('serviceProviderEntityId', urlencode($spMetadata['EntityId']))->setParameterGet('identityProviderEntityId', urlencode($idpMetadata['EntityId']))->request('GET');
$body = $client->getLastResponse()->getBody();
$response = json_decode($body, true);
$status = $response['status'];
} catch (Exception $exception) {
$additionalInfo = new EngineBlock_Log_Message_AdditionalInfo($userId, $idpMetadata['EntityId'], $spMetadata['EntityId'], $exception->getTraceAsString());
EngineBlock_ApplicationSingleton::getLog()->error("Could not connect to License Manager" . $exception->getMessage(), $additionalInfo);
return EngineBlock_LicenseEngine_ValidationManager::LICENSE_UNKNOWN;
}
if ($status['returnUrl']) {
$currentResponse = EngineBlock_ApplicationSingleton::getInstance()->getHttpResponse();
$currentResponse->setRedirectUrl($status['returnUrl']);
$currentResponse->send();
exit;
} else {
if ($status['licenseStatus']) {
return $status['licenseStatus'];
} else {
return EngineBlock_LicenseEngine_ValidationManager::LICENSE_UNKNOWN;
}
}
}
示例9: logoutAction
public function logoutAction()
{
$serverUrl = 'http://' . AUTH_SERVER . self::AUTH_PATH . '/logout';
$client = new Zend_Http_Client($serverUrl, array('timeout' => 30));
try {
if (isset($_COOKIE[self::AUTH_SID])) {
$moduleName = $this->getRequest()->getModuleName();
$client->setCookie('PHPSESSID', $_COOKIE[self::AUTH_SID]);
$client->setCookie('moduleName', $moduleName);
$response = $client->request();
if ($response->isError()) {
$remoteErr = $response->getStatus() . ' : ' . $response->getMessage() . '<br/>' . $response->getBody();
throw new Zend_Exception($remoteErr, Zend_Log::ERR);
}
} else {
$this->_helper->logger('No remote cookie found');
}
} catch (Zend_Exception $e) {
echo $e->getMessage();
}
if (isset($_COOKIE[self::AUTH_SID])) {
preg_match('/[^.]+\\.[^.]+$/', $_SERVER['SERVER_NAME'], $domain);
setcookie(self::AUTH_SID, '', time() - 360000, self::AUTH_PATH, ".{$domain['0']}");
}
Zend_Auth::getInstance()->clearIdentity();
Zend_Session::destroy();
}
示例10: getContent
/**
* returns the content of this item
*
* @return string content
*/
public function getContent()
{
if ($this->items !== false && $this->valid()) {
try {
// load entry page
$client = new Zend_Http_Client($this->getLink() . '?page=all');
$response = $client->request();
$content = $response->getBody();
$content = utf8_decode($content);
// parse content
$dom = new Zend_Dom_Query($content);
$text = $dom->query('.article');
$innerHTML = '';
// convert innerHTML from DOM to string
// taken from http://us2.php.net/domelement (patrick smith)
$children = $text->current()->childNodes;
foreach ($children as $child) {
$tmp_doc = new DOMDocument();
$tmp_doc->appendChild($tmp_doc->importNode($child, true));
if (count($tmp_doc->getElementById('comments')) > 0) {
continue;
}
// convert to text
$innerHTML .= @$tmp_doc->saveHTML();
}
return $innerHTML;
} catch (Exception $e) {
// return default content
return current($this->items)->get_content();
}
}
}
示例11: _request
/**
*
*/
protected function _request($url, $params, $method = Zend_Http_Client::GET)
{
$this->_client->setUri($url)->resetParameters();
if (count($params['header'])) {
foreach ($params['header'] as $name => $value) {
$this->_client->setHeaders($name, $value);
}
}
if (count($params['post'])) {
foreach ($params['post'] as $name => $value) {
$this->_client->setParameterPost($name, $value);
}
}
if (count($params['get'])) {
foreach ($params['get'] as $name => $value) {
$this->_client->setParameterGet($name, $value);
}
}
if (count($params['json'])) {
//$this->_client->setHeaders('Content-type','application/json');
$rawJson = json_encode($params['json']);
//$this->_client->setRawData($rawJson);
$this->_client->setRawData($rawJson, 'application/json');
}
$response = $this->_client->request($method);
$result = $response->getBody();
#echo $result . "\n\n <br>";
return json_decode($result);
}
示例12: getCoordinates
/**
* Gibt die Geokoordinaten anhand einer Adresse zurück
*
* @param string $address Die Adresse die geocodet werden woll
* @return array|null $geocode Ein Array mit key 'lat' und 'lng'
*/
public static function getCoordinates($address)
{
$q = $address;
$q = str_replace(array('ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü', 'ß'), array('ae', 'oe', 'ue', 'Ae', 'Oe', 'Ue', 'ss'), $q);
$getParams = array('address' => $q, 'sensor' => 'false');
$httpClientConfig = array('timeout' => 20, 'persistent' => false);
$config = Kwf_Registry::get('config');
if ($config->http && $config->http->proxy && $config->http->proxy->host && $config->http->proxy->port) {
$httpClientConfig['adapter'] = 'Zend_Http_Client_Adapter_Proxy';
$httpClientConfig['proxy_host'] = $config->http->proxy->host;
$httpClientConfig['proxy_port'] = $config->http->proxy->port;
}
$client = new Zend_Http_Client("http://maps.googleapis.com/maps/api/geocode/json", $httpClientConfig);
$client->setMethod(Zend_Http_Client::GET);
$client->setParameterGet($getParams);
$body = utf8_encode($client->request()->getBody());
try {
$result = Zend_Json::decode($body);
} catch (Zend_Json_Exception $e) {
$e = new Kwf_Exception_Other($e);
$e->logOrThrow();
}
if (isset($result['results'][0]['geometry']['location']['lat']) && isset($result['results'][0]['geometry']['location']['lng'])) {
return array('lat' => $result['results'][0]['geometry']['location']['lat'], 'lng' => $result['results'][0]['geometry']['location']['lng']);
}
return null;
}
示例13: send
function send()
{
global $tikilib;
$entry = array();
$lastModif = 0;
$feed = $this->feed();
foreach ($feed->feed->entry as $item) {
if (empty($item->forwardlink->href)) {
continue;
}
$client = new Zend_Http_Client($item->forwardlink->href, array('timeout' => 60));
$info = $tikilib->get_page_info($item->page);
if ($info['lastModif'] > $lastModif) {
$lastModif = $info['lastModif'];
}
}
if (!empty($feed->feed->entry)) {
$client->setParameterGet(array('protocol' => 'forwardlink', 'contribution' => json_encode($feed)));
try {
$response = $client->request(Zend_Http_Client::POST);
$request = $client->getLastResponse();
return $response->getBody();
} catch (Exception $e) {
return "";
}
}
}
示例14: curlAction
public function curlAction()
{
$base_url = "http://localhost:8080/NRServices/services/hello/hello/jack";
$config = array('adapter' => 'Zend_Http_Client_Adapter_Curl', 'curloptions' => array(CURLOPT_FOLLOWLOCATION => true));
$http_client = new Zend_Http_Client($base_url, $config);
$this->view->response = $http_client->request(Zend_Http_Client::GET);
}
示例15: _purgeCacheServers
/**
* Process all servers
*/
protected function _purgeCacheServers(array $headers)
{
$servers = $this->_getVarnishServers();
if (empty($servers)) {
return;
}
// process all servers
foreach ($servers as $server) {
// compile url string with scheme, domain/server and port
$uri = 'http://' . $server;
if ($port = trim(Mage::getStoreConfig(self::XML_PATH_VARNISH_PORT))) {
$uri .= ':' . $port;
}
$uri .= '/';
try {
// create HTTP client
$client = new Zend_Http_Client();
$client->setUri($uri)->setHeaders($headers)->setConfig(array('timeout' => 15));
// send PURGE request
$response = $client->request('PURGE');
// check response
if ($response->getStatus() != '200') {
throw new Exception('Return status ' . $response->getStatus());
}
} catch (Exception $e) {
Mage::helper('varnishcache')->debug('Purging on server ' . $server . ' failed (' . $e->getMessage() . ').');
}
}
}