本文整理汇总了PHP中Zend_Http_Client::setParameterPost方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Client::setParameterPost方法的具体用法?PHP Zend_Http_Client::setParameterPost怎么用?PHP Zend_Http_Client::setParameterPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Http_Client
的用法示例。
在下文中一共展示了Zend_Http_Client::setParameterPost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSintegraHtmlData
private function getSintegraHtmlData($num_cnpj, $proxy = '', $url = 'http://www.sintegra.es.gov.br/resultado.php')
{
try {
// Configurações da conexão HTTP com a página
$zendHttpConfig = array('adapter' => 'Zend_Http_Client_Adapter_Socket', 'ssltransport' => 'tls', 'timeout' => 15);
if (is_array($proxy)) {
$zendHttpConfig['proxy_host'] = $proxy['HOST'];
$zendHttpConfig['proxy_port'] = $proxy['PORT'];
}
// Criar o objeto que fara a requisição HTTP
$zendHttpClient = new Zend_Http_Client($url);
$zendHttpClient->setConfig($zendHttpConfig);
// Definir os parâmetros POST enviados a página
// Obs: O parâmetro "botao" é obrigatório
$zendHttpClient->setParameterPost('num_cnpj', $num_cnpj);
$zendHttpClient->setParameterPost('botao', 'Consultar');
// Fazer requisição da página (método POST)
$response = $zendHttpClient->request(Zend_Http_Client::POST);
// Retornar o corpo da página
if ($response->isError()) {
throw new Exception($response->getStatus());
} else {
return $response->getBody();
}
} catch (Exception $e) {
$erro = $e->message;
die("Erro ao buscar informações no Sintegra. Erro: " . $erro);
}
}
示例2: _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);
}
示例3: request
/**
* Load XML response from Correios
*
* @param string $number Tracking Code
*
* @throws Zend_Http_Client_Adapter_Exception
*
* @link http://www.correios.com.br/para-voce/correios-de-a-a-z/pdf/rastreamento-de-objetos/
* Manual_SROXML_28fev14.pdf
*
* @return SimpleXMLElement
*/
public function request($number)
{
$client = new Zend_Http_Client($this->getConfigData("url_sro_correios"));
$client->setParameterPost('Usuario', $this->getConfigData('sro_username'));
$client->setParameterPost('Senha', $this->getConfigData('sro_password'));
$client->setParameterPost('Tipo', $this->getConfigData('sro_type'));
$client->setParameterPost('Resultado', $this->getConfigData('sro_result'));
$client->setParameterPost('Objetos', $number);
try {
$response = $client->request(Zend_Http_Client::POST)->getBody();
if (empty($response)) {
throw new Zend_Http_Client_Adapter_Exception("Empty response");
}
libxml_use_internal_errors(true);
$this->_xml = simplexml_load_string($response);
if (!$this->_xml || !isset($this->_xml->objeto)) {
throw new Zend_Http_Client_Adapter_Exception("Invalid XML");
}
} catch (Zend_Http_Exception $e) {
Mage::log("{$e->getMessage()}");
Mage::log("TRACKING: {$number}");
Mage::log("RESPONSE: {$response}");
return false;
}
return $this;
}
示例4: publishUpdate
public function publishUpdate($topicUrls)
{
if (!isset($topicUrls)) {
throw new Kwf_Exception('Please specify a topic url');
}
if (!is_array($topicUrls)) {
$topicUrls = array($topicUrls);
}
$client = new Zend_Http_Client($this->_hubUrl);
$client->setConfig(array('timeout' => 60, 'persistent' => true));
$client->setMethod(Zend_Http_Client::POST);
$data = array('hub.mode' => 'publish');
$client->setParameterPost($data);
foreach ($topicUrls as $u) {
if (!preg_match("|^https?://|i", $u)) {
throw new Kwf_Exception('The specified topic url does not appear to be valid: ' . $topicUrl);
}
$client->setParameterPost('hub.url', $u);
}
$response = $client->request();
if ($response->isError()) {
throw new Kwf_Exception("publishUpdate failed, response status '{$response->getStatus()}' '{$response->getBody()}'");
}
return $response;
}
示例5: add
public function add($graph, $turtle)
{
$post_endpoint = array_shift(split("/sparql/", $this->_endpoint)) . "/data/";
$client = new Zend_Http_Client();
$client->setUri($post_endpoint);
$client->setParameterPost('graph', $graph);
$client->setParameterPost('data', FourStore_Namespace::to_turtle() . $turtle);
$client->setParameterPost('mime-type', 'application/x-turtle');
$response = $client->request('POST');
return $response;
}
示例6: request
/**
* Execute CheddarGetter API request
*
* @param string $url Url to the API action
* @param string $username Username
* @param string $password Password
* @param array|null $args HTTP post key value pairs
* @return string Body of the response from the CheddarGetter API
* @throws Zend_Http_Client_Exception A Zend_Http_Client_Exception may
* be thrown under a number of conditions but most likely if the tcp socket
* fails to connect.
*/
public function request($url, $username, $password, array $args = null)
{
// reset
$this->_client->setUri($url);
$this->_client->resetParameters();
$this->_client->setMethod(Zend_Http_Client::GET);
$this->_client->setAuth($username, $password);
if ($args) {
$this->_client->setMethod(Zend_Http_Client::POST);
$this->_client->setParameterPost($args);
}
$response = $this->_client->request();
return $response->getBody();
}
示例7: getHttpClient
/**
* Set Google authentication credentials.
* Must be done before trying to do any Google Data operations that
* require authentication.
* For example, viewing private data, or posting or deleting entries.
*
* @param string $email
* @param string $password
* @param string $service
* @param Zend_Http_Client $client
* @param string $source
* @return Zend_Http_Client
* @throws Zend_Gdata_AuthException
* @throws Zend_Gdata_HttpException
*/
public function getHttpClient($email, $password, $service = 'xapi', $client = null, $source = self::DEFAULT_SOURCE)
{
if (!($email && $password)) {
throw new Zend_Gdata_AuthException('Please set your Google credentials before trying to authenticate');
}
if ($client == null) {
$client = new Zend_Http_Client();
}
if (!$client instanceof Zend_Http_Client) {
throw new Zend_Gdata_HttpException('Client is not an instance of Zend_Http_Client.');
}
// Build the HTTP client for authentication
$client->setUri(self::CLIENTLOGIN_URI);
$client->setConfig(array('maxredirects' => 0, 'strictredirects' => true));
$client->setParameterPost('accountType', 'HOSTED_OR_GOOGLE');
$client->setParameterPost('Email', (string) $email);
$client->setParameterPost('Passwd', (string) $password);
$client->setParameterPost('service', (string) $service);
$client->setParameterPost('source', (string) $source);
// Send the authentication request
// For some reason Google's server causes an SSL error. We use the
// output buffer to supress an error from being shown. Ugly - but works!
ob_start();
try {
$response = $client->request('POST');
} catch (Zend_Http_Client_Exception $e) {
throw new Zend_Gdata_HttpException($e->getMessage(), $e);
}
ob_end_clean();
// Parse Google's response
$goog_resp = array();
foreach (explode("\n", $response->getBody()) as $l) {
$l = chop($l);
if ($l) {
list($key, $val) = explode('=', chop($l), 2);
$goog_resp[$key] = $val;
}
}
if ($response->getStatus() == 200) {
$headers['authorization'] = 'GoogleLogin auth=' . $goog_resp['Auth'];
$client = new Zend_Http_Client();
$client->setConfig(array('strictredirects' => true));
$client->setHeaders($headers);
return $client;
} elseif ($response->getStatus() == 403) {
throw new Zend_Gdata_AuthException('Authentication with Google failed. Reason: ' . (isset($goog_resp['Error']) ? $goog_resp['Error'] : 'Unspecified.'));
}
}
示例8: sendPOST
/**
* Send a POST request to the specified URL with the specified payload.
* @param string $url
* @param string $data
* @return string Remote data
**/
public function sendPOST($url, $data = array())
{
$data['_fake_status'] = '200';
// Zend makes it easier than the others...
$this->instance->setConfig(array('useragent' => sprintf(Imgur::$user_agent, Imgur::$key)));
$this->instance->setMethod(Zend_Http_Client::POST);
$this->instance->setUri($url);
$this->instance->setParameterPost($data);
try {
/** @var Zend_Http_Response */
$response = $this->instance->request();
return $response->getBody();
} catch (Exception $e) {
throw new Imgur_Exception("Unknown Failure during HTTP Request", null, $e);
}
}
示例9: viewemailidsAction
public function viewemailidsAction()
{
$this->_helper->viewRenderer->setNoRender(true);
$this->_helper->layout()->disableLayout();
$member_ids = array(1, 2, 3, 4, 5);
$httpClient = new Zend_Http_Client('http://' . CORE_SERVER . '/student/fetchemailids');
//$httpClient->setCookie('PHPSESSID', $_COOKIE['PHPSESSID']);
$httpClient->setMethod('POST');
$call_back = 'viewbatchinfo';
$httpClient->setParameterPost(array('member_ids' => $member_ids, 'format' => 'json', 'call_back' => $call_back));
$response = $httpClient->request();
if ($response->isError()) {
$remoteErr = 'REMOTE ERROR: (' . $response->getStatus() . ') ' . $response->getHeader('Message') . $response->getBody();
throw new Zend_Exception($remoteErr, Zend_Log::ERR);
} else {
$jsonContent = $response->getBody($response);
Zend_Registry::get('logger')->debug($jsonContent);
Zend_Registry::get('logger')->debug(Zend_Json_Decoder::decode($jsonContent));
Zend_Registry::get('logger')->debug(json_decode($jsonContent));
/*Zend_Registry::get('logger')->debug(
Zend_Json_Decoder::decode($jsonContent));*/
/*$r = Zend_Json_Decoder::decode($jsonContent);
$batch_info = $r['batch_info'];
Zend_Registry::get('logger')->debug($batch_info);*/
}
}
示例10: makeRequest
public function makeRequest($payload)
{
try {
$payload = array_merge($payload, $this->_getPayloadBase());
$client = new Zend_Http_Client(self::REMARKETY_URI, $this->_getRequestConfig());
$client->setParameterPost($payload);
$response = $client->request(self::REMARKETY_METHOD);
Mage::log(var_export($payload, true), null, 'remarkety-ext.log');
Mage::log($response->getStatus(), null, 'remarkety-ext.log');
Mage::log($response->getBody(), null, 'remarkety-ext.log');
$body = (array) json_decode($response->getBody());
Mage::getSingleton('core/session')->setRemarketyLastResponseStatus($response->getStatus() === 200 ? 1 : 0);
Mage::getSingleton('core/session')->setRemarketyLastResponseMessage(serialize($body));
switch ($response->getStatus()) {
case '200':
return $body;
case '400':
throw new Exception('Request failed. ' . $body['message']);
default:
throw new Exception('Request to remarkety servers failed (' . $response->getStatus() . ')');
}
} catch (Exception $e) {
Mage::log($e->getMessage(), null, 'remarkety-ext.log');
throw new Mage_Core_Exception($e->getMessage());
}
}
示例11: _sendRestRequest
/**
* @description send REST request
* @throws Exception
* @return string
* @author Se#
* @version 0.0.3
*/
protected function _sendRestRequest($args, $config)
{
if (!isset($args['action']) && !isset($config['default']['action'])) {
throw new Exception(' Missed "action" in the arguments and configuration');
}
$do = isset($args['action']) ? $args['action'] : $config['default']['action'];
$doConfig = isset($config['actions'][$do]) ? $config['actions'][$do] : array();
$default = isset($config['default']) ? $config['default'] : array();
$url = $this->_getUrl($args, $doConfig, $default);
$required = $this->_getRequired($args, $doConfig, $default);
$data = isset($args['data']) ? $args['data'] : array();
$data = $this->_checkDataByRequired($data, $required);
/**
* Convert rub in copicks
*/
if (isset($data['amount'])) {
$data['amount'] = floor($data['amount'] * 100);
}
$client = new Zend_Http_Client($url);
//print_r($data);
foreach ($data as $name => $value) {
$client->setParameterPost($name, $value);
}
/**
* FIXME: getRawBody() adds additional characters to response
* maybe wrong
* Zend-Framework 1.11.4
*/
//$result = $client->request('POST')->getRawBody();
$result = $client->request('POST')->getBody();
return $result;
}
示例12: 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();
}
示例13: execute
/**
* @see Console\Command\Command
*/
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
$supportSend = \SystemPref::get('support_send');
if ($supportSend) {
$stats = $this->getHelper('container')->getService('stat')->getAll();
$statsUrl = 'http://stat.sourcefabric.org';
$parameters = array('p' => 'newscoop');
$parameters['installation_id'] = $stats['installationId'];
$parameters['server'] = \SystemPref::get('support_stats_server');
$parameters['ip_address'] = \SystemPref::get('support_stats_ip_address');
$parameters['ram_used'] = $stats['ramUsed'];
$parameters['ram_total'] = \SystemPref::get('support_stats_ram_total');
$parameters['version'] = $stats['version'];
$parameters['install_method'] = $stats['installMethod'];
$parameters['publications'] = $stats['publications'];
$parameters['issues'] = $stats['issues'];
$parameters['sections'] = $stats['sections'];
$parameters['articles'] = $stats['articles'];
$parameters['articles_published'] = $stats['articlesPublished'];
$parameters['languages'] = $stats['languages'];
$parameters['authors'] = $stats['authors'];
$parameters['subscribers'] = $stats['subscribers'];
$parameters['backend_users'] = $stats['backendUsers'];
$parameters['images'] = $stats['images'];
$parameters['attachments'] = $stats['attachments'];
$parameters['topics'] = $stats['topics'];
$parameters['comments'] = $stats['comments'];
$parameters['hits'] = $stats['hits'];
$client = new \Zend_Http_Client();
$client->setUri($statsUrl);
$client->setParameterPost($parameters);
$response = $client->request('POST');
}
}
示例14: 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));
}
}
示例15: updateAction
public function updateAction()
{
$form = new Application_Form_Job();
$form->submit->setLabel('Update');
$this->view->form = $form;
if ($this->getRequest()->isPost()) {
$jobData = $this->getRequest()->getPost();
if ($form->isValid($jobData)) {
$jobData['createTime'] = new MongoDate();
$jobData['modifyTime'] = new MongoDate();
$id = (int) $jobData['id'];
$client = new Zend_Http_Client('http://api.dm/public/job/' . $id);
var_dump($id);
$client->setMethod(Zend_Http_Client::DELETE);
$client->request();
$client = new Zend_Http_Client('http://api.dm/public/job');
$client->setMethod(Zend_Http_Client::POST);
$client->setParameterPost($jobData);
$client->request();
$this->_helper->redirector('index');
} else {
$form->populate($jobData);
}
} else {
$id = $this->_getParam('id');
$client = new Zend_Http_Client('http://api.dm/public/job/' . $id);
$job = json_decode($client->request()->getBody());
$form->populate((array) $job);
}
}