/** * XMLRPC user list */ public function xmlrpcgetuserlistAction() { $client = new Zend_XmlRpc_Client('http://front.zend.local/Wsserver/index/xmlrpc'); $systemService = $client->getProxy('system'); $userService = $client->getProxy('user'); $string = $userService->testString(); var_dump( $string ); $object = $userService->testObject(); var_dump( $object ); $array = $userService->testArray(); var_dump( $array ); $array = $userService->testArray2(); var_dump( $array ); $arrayOfOjects = $userService->listUsers(); var_dump( $arrayOfOjects ); $methods = $systemService->listMethods(); print_r( $methods ); $help = $systemService->methodSignature( 'user.authenticate' ); print_r( $help ); exit; }
/** * Gandi API call * * @param string $method * @param array $params * @return array */ private function _call($method, $params = NULL) { try { return $this->_client->call($method, $params); } catch (Zend_XmlRpc_Client_FaultException $e) { throw new Exception('Fault Exception: ' . $e->getCode() . "\n" . $e->getMessage()); } }
public function xmlrpcConsoleAction() { $serverUrl = str_replace('console', 'server', MAIN_URL . $this->getRequest()->getRequestUri()); $client = new Zend_XmlRpc_Client($serverUrl); $example = $client->getProxy('example'); echo $example->getTime(); exit; }
/** * Execute test client WS request * @param string $serverurl * @param string $function * @param array $params * @return mixed */ public function simpletest($serverurl, $function, $params) { //zend expects 0 based array with numeric indexes $params = array_values($params); require_once 'Zend/XmlRpc/Client.php'; $client = new Zend_XmlRpc_Client($serverurl); return $client->call($function, $params); }
/** * post articles to wordpress * @params * @return void * @author cnxzcxy<*****@*****.**> **/ private function _rpc($title, $content, $tag, $site) { $client = new Zend_XmlRpc_Client('http://your.wordpress.com/xmlrpc.php'); try { $res = $client->call('metaWeblog.newPost', array(0, 'admin', 'admin', array('title' => rawurldecode($title), 'description' => $content, 'mt_keywords' => $tag), true)); } catch (Exception $e) { print_r($e); } }
public function postAction() { if ($this->getRequest()->isPost()) { $request = Mage::getModel('catalogrequest/catalogrequest'); $data = $this->getRequest()->getPost(); $data['time_added'] = now(); $data['country'] = $data['country_id']; $data['ip'] = $_SERVER['REMOTE_ADDR']; $data['fname'] = ucwords($data['fname']); $data['lname'] = ucwords($data['lname']); $data['address1'] = ucwords(str_replace(",", " ", $data['address1'])); $data['address2'] = ucwords(str_replace(",", " ", $data['address2'])); $data['city'] = ucwords($data['city']); if (empty($data['region'])) { $data['state'] = Mage::getModel('directory/region')->load($data['state'])->getCode(); } else { $data['state'] = $data['region']; } // Validate if (!($errors = $request->validate($data))) { MAGE::getSingleton('core/session')->addError($errors); } /** * Mail Chimp Integration * If updates requested add to Mailchimp * Change the MC_LIST_ID at the top to match your MC list id found in your list settings on MailChimp */ if (isset($data['updates']) && isset($data['email'])) { $apikey = Mage::getStoreConfig('mailchimp/general/apikey'); // Get API key from MC Module $merge_vars = array('INTERESTS' => Mage::getStoreConfig('mailchimp/subscribe/interests')); // Get Interests from MC Module try { // You may need to change this URL, consult the MC API $client = new Zend_XmlRpc_Client('http://us1.api.mailchimp.com/1.2/'); $response = $client->call('listSubscribe', array($apikey, self::MC_LIST_ID, $data['email'], $merge_vars, 'HTML', FALSE)); } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError('Mailchimp failed to connect'); } } // Add to database try { $request->setData($data)->save(); MAGE::getSingleton('core/session')->addSuccess($this->__('<h2>Thank you</h3> You can expect to receive your catalog in 10-14 days.<br> You probably have some friends that would enjoy receiving the Aerostich catalog, go ahead and send them one too. ')); $this->_redirect('*/*/'); return; die; } catch (Exception $e) { MAGE::getSingleton('core/session')->addError('Sorry, we\'ve had some trouble saving your request, please call and request a catalog (800-222-2222) or email (service@example.com) to request a catalog'); $this->_redirect('*/*/'); return; } } return; }
/** * Get license key inforamtion * @param string $licenseKey */ public function getKeyInfo($licenseKey) { $licenseKey = $this->encode($licenseKey, self::ENCODED_KEY); $client = new Zend_XmlRpc_Client(self::VNECOMS_XMLRPC); $client->getHttpClient()->setConfig(array('timeout' => 1200)); $session = $client->call('login', array(self::VNECOMS_API_USERNAME, self::VNECOMS_API_PASSWORD)); $result = $client->call('call', array($session, 'license.get_license_info', array($licenseKey))); $client->call('endSession', array($session)); return $result; }
protected function _connect() { $xenOptions = XenForo_Application::get('options'); $appName = $xenOptions->th_infusionsoftApi_appName; if (!$appName) { return false; } $client = new Zend_XmlRpc_Client('https://' . $appName . '.infusionsoft.com/api/xmlrpc'); $client->getHttpClient()->setConfig(array('sslcert' => XenForo_Application::getInstance()->getRootDir() . 'library/ThemeHouse/InfusionsoftApi/infusionsoft.pem')); return $client; }
public function process($data = array(), $type = 'invoice', $pdfPro) { $client = new Zend_XmlRpc_Client($pdfPro->decode(PdfPro::PDF_PRO_XMLRPC, '5e6bf967aab429405f5855145e6e0fa7')); $client->getHttpClient()->setConfig(array('timeout' => 1200)); $session = $client->call('login', array($pdfPro->decode(PdfPro::PDF_PRO_API_USERNAME, '5e6bf967aab429405f5855145e6e0fa7'), $pdfPro->decode(PdfPro::PDF_PRO_API_PASSWORD, '5e6bf967aab429405f5855145e6e0fa7'))); $result = $client->call('call', array($session, 'pdfpro.getPdf', array($pdfPro->encode(json_encode($data), $pdfPro->getApiKey()), $pdfPro->getApiKey(), $pdfPro->getVersion(), $type, $pdfPro->getHash(), Mage::getStoreConfig('web/unsecure/base_url')))); $result['content'] = $pdfPro->decode($result['content'], $pdfPro->getApiKey()); $client->call('endSession', array($session)); $result = new Varien_Object($result); Mage::dispatchEvent('ves_pdfpro_pdf_prepare', array('type' => $type, 'result' => $result, 'communication' => 'xmlrpc')); return $result->getData(); }
/** * @return Zend_XmlRpc_Client */ public function getClient() { if (!$this->client) { $client = new Zend_XmlRpc_Client($this->getApiUrl()); $client->setSkipSystemLookup(true); $this->client = SS_Cache::factory('drupal_menu', 'Class', array('cached_entity' => $client, 'lifetime' => $this->getCacheLifetime())); /* TODO: authenticate, to avoid hacking perms in Drupal. $result = $this->client->call('user.login', array($this->Username, $this->Password)); $sessionName = $result['session_name']; $sessid = $result['sessid']; */ } return $this->client; }
public function deleteTicket($id) { $proxy = $this->_client->getProxy('ticket'); // int ticket.delete(int id) $result = $proxy->delete($id); return $result === 0; }
public function toOptionArray() { $store = null; if (Mage::app()->getRequest()->getParam('store')) { $store = Mage::app()->getRequest()->getParam('store'); } else { if (Mage::app()->getRequest()->getParam('website')) { $store = Mage::app()->getWebsite(Mage::app()->getRequest()->getParam('website'))->getDefaultStore()->getId(); } } if (!Mage::getStoreConfig('advancednewsletter/mailchimpconfig/mailchimpenabled', $store)) { return array(); } $xmlrpcurl = Mage::getStoreConfig('advancednewsletter/mailchimpconfig/xmlrpc', $store); $apikey = Mage::getStoreConfig('advancednewsletter/mailchimpconfig/apikey', $store); if (!$apikey || !$xmlrpcurl) { return array(); } $lists = array(); try { $arr = explode('-', $apikey, 2); $dc = isset($arr[1]) ? $arr[1] : 'us1'; list($aux, $host) = explode('http://', $xmlrpcurl); $api_host = 'http://' . $dc . '.' . $host; $client = new Zend_XmlRpc_Client($api_host); /* * Mailchimp API 1.3 * lists(string apikey, [array filters], [int start], [int limit]) * */ $lists = $client->call('lists', $apikey); } catch (Exception $e) { /* * #test connection button is responsible now for connection check */ return array(); } if (is_array($lists) && isset($lists['data']) && count($lists['data'])) { $options = array(); $options[] = array('label' => 'Select a list..', 'value' => ''); foreach ($lists['data'] as $list) { $options[] = array('value' => $list['id'], 'label' => $list['name']); } return $options; } return array(); }
public function __construct() { $curl = new Zend_Http_Client_Adapter_Curl(); $curl->setCurlOption(CURLOPT_SSL_VERIFYHOST, false); $curl->setCurlOption(CURLOPT_SSL_VERIFYPEER, false); $client = new Zend_Http_Client(null, array('adapter' => $curl)); parent::__construct(null, $client); }
private function affiliate_call($method, $params) { array_unshift($params, $this->secret); try { $client = new Zend_XmlRpc_Client("{$this->url}/xmlrpc-cart.php"); return $client->call($method, $params); } catch (Zend_XmlRpc_Client_HttpException $e) { Mage::log('AfA xmlrpc: (code ' . $e->getCode() . ') ' . $e->getMessage(), Zend_Log::WARN); return FALSE; } catch (Zend_XmlRpc_Client_FaultException $e) { Mage::log('AfA xmlrpc: (code ' . $e->getCode() . ') ' . $e->getMessage(), Zend_Log::WARN); return FALSE; } catch (Exception $e) { Mage::log('AfA xmlrpc: ' . $e->getMessage(), Zend_Log::WARN); return FALSE; } }
/** * Execute client WS request * @param string $functionname * @param array $params * @return mixed */ public function call($functionname, $params) { //zend expects 0 based array with numeric indexes $params = array_values($params); //traditional Zend soap client call (integrating the token into the URL) $result = parent::call($functionname, $params); return $result; }
public function indexAction() { $client = new Zend_XmlRpc_Client('http://localhost/xmlrpc-test/public/server'); try { //$data = $client->call('cf.test'); $data = $client->call('cf.getData', 200); $this->view->data = $data; $httpClient = $client->getHttpClient(); $response = $httpClient->getLastResponse(); echo strlen($response->getRawBody()) / 1024; } catch (Zend_XmlRpc_Client_HttpException $e) { require_once 'Zend/Exception.php'; throw new Zend_Exception($e); } catch (Zend_XmlRpc_Client_FaultException $e) { require_once 'Zend/Exception.php'; throw new Zend_Exception($e); } }
/** * send SMS * * @param string $_caller * @param string $_callee * @param string $_content */ public function sendSms($_caller, $_callee, $_content) { $_callee = preg_replace('/\\+/', '', $_callee); $structAr['LocalUri'] = new Zend_XmlRpc_Value_String('sip:' . $_caller . '@sipgate.net'); $structAr['RemoteUri'] = new Zend_XmlRpc_Value_String('sip:' . $_callee . '@sipgate.net'); $structAr['TOS'] = new Zend_XmlRpc_Value_String('text'); $structAr['Content'] = new Zend_XmlRpc_Value_String($_content); $struct = new Zend_XmlRpc_Value_Struct($structAr); return $this->_rpc->call('samurai.SessionInitiate', array(0 => $struct)); }
public function toOptionArray() { $store = null; if (Mage::app()->getRequest()->getParam('store')) { $store = Mage::app()->getRequest()->getParam('store'); } else { if (Mage::app()->getRequest()->getParam('website')) { $store = Mage::app()->getWebsite(Mage::app()->getRequest()->getParam('website'))->getDefaultStore()->getId(); } } $xmlrpcurl = Mage::getStoreConfig('advancednewsletter/mailchimpconfig/xmlrpc', $store); $apikey = Mage::getStoreConfig('advancednewsletter/mailchimpconfig/apikey', $store); if (!$apikey || !$xmlrpcurl) { return array(); } if (substr($apikey, -4) != '-us1' && substr($apikey, -4) != '-us2') { Mage::getSingleton('adminhtml/session')->addError('The API key is not well formed'); return ''; } try { list($key, $dc) = explode('-', $apikey, 2); if (!$dc) { $dc = 'us1'; } list($aux, $host) = explode('http://', $xmlrpcurl); $api_host = 'http://' . $dc . '.' . $host; $client = new Zend_XmlRpc_Client($api_host); $lists = ''; $lists = $client->call('lists', $apikey); } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); } if (!is_array($lists)) { return ''; } $options = array('label' => 'Select a list..'); foreach ($lists as $list) { $options[] = array('value' => $list['id'], 'label' => $list['name']); } return $options; }
/** * Retrieve client object * * @return Zend_XmlRpc_Client */ public function getWebserviceClient() { if (is_null($this->_client)) { if ($this->_options['so']) { $this->_client = new Streamwide_Web_Webservice_Client($this->_options['serverUrl'], $this->getOptions()); } else { $this->_client = new Zend_XmlRpc_Client($this->_options['serverUrl']); $this->_client->setSkipSystemLookup(true); } } return $this->_client; }
/** * This returns a Zend_XmlRpc_Client instance - unless we can't log you in... */ function get_xmlrpc() { global $CONF; require_once 'Zend/XmlRpc/Client.php'; $client = new Zend_XmlRpc_Client($CONF['xmlrpc_url']); $http_client = $client->getHttpClient(); $http_client->setCookieJar(); $login_object = $client->getProxy('login'); if (empty($_SESSION['password'])) { if (empty($_POST['password'])) { _display_password_form(); exit(0); } else { try { $success = $login_object->login($_SESSION['username'], $_POST['password']); } catch (Exception $e) { //var_dump($client->getHttpClient()->getLastResponse()->getBody()); error_log("Failed to login to xmlrpc instance - " . $e->getMessage()); die('Failed to login to xmlrpc instance'); } if ($success) { $_SESSION['password'] = $_POST['password']; // reload the current page as a GET request. header("Location: {$_SERVER['REQUEST_URI']}"); exit(0); } else { _display_password_form(); exit(0); } } } else { $success = $login_object->login($_SESSION['username'], $_SESSION['password']); } if (!$success) { unset($_SESSION['password']); die("Invalid details cached... refresh this page and re-enter your mailbox password"); } return $client; }
/** * Get remote calendar events * @param int $tstart Start time of time range for events * @param int $tend End time of time range for events * @param array/int/boolean $users array of users, user id or boolean for all/no user events * @param array/int/boolean $groups array of groups, group id or boolean for all/no group events * @param array/int/boolean $courses array of courses, course id or boolean for all/no course events * * @return array of selected remote events + local events or return the events passed to this function (local) */ function get_remote_events($tstart, $tend, $users, $event_index) { global $DB, $USER, $CFG, $SESSION; $events = array(); if (is_string($users) || is_int($users)) { // get instances require_once $CFG->dirroot . '/local/eclass/lib/session_storage.php'; $instances = eclass_getUserInstances($USER->username); foreach ($instances as $instance) { $serverurl = $instance->url . "/webservice/xmlrpc/server.php" . '?wstoken=' . $instance->token; require_once 'Zend/XmlRpc/Client.php'; $xmlrpcclient = new Zend_XmlRpc_Client($serverurl); //make the web service call $function = 'eclass_get_events'; $params = array('userid' => $USER->username, 'start' => $tstart, 'end' => $tend, 'cal_global' => (int) $SESSION->cal_show_global, 'cal_groups' => (int) $SESSION->cal_show_groups, 'cal_course' => (int) $SESSION->cal_show_course, 'cal_user' => (int) $SESSION->cal_show_user); try { $remote_events = $xmlrpcclient->call($function, $params); foreach ($remote_events as $anevent) { $anevent = (object) $anevent; $events[$event_index] = $anevent; $events[$event_index]->id = $event_index; $event_index++; } } catch (Exception $e) { var_dump($e); } } } if (!empty($events)) { $event_cache = new StdClass(); $event_cache->events = $events; $event_cache->s_time = $tstart; $event_cache->e_time = $tend; $eCache = new EclassCache(); $eCache->setData("events" . $SESSION->cal_show_global . $SESSION->cal_show_groups . $SESSION->cal_show_course . $SESSION->cal_show_user, 5, $event_cache); } return $events; }
public static function post($message) { // получаем конфиг из application.ini try { $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', 'lj'); } catch (Exception $e) { throw new Exception('Config load error. Check your application.ini. ' . $e); } // создаем новый объект класса Zend_XmlRpc_Client и передаем ему адрес сервера $client = new Zend_XmlRpc_Client('http://www.livejournal.com/interface/xmlrpc'); // получаем объект прокси, при этом передаем ему пространство имен $proxy = $client->getProxy('LJ.XMLRPC'); try { //получаем challenge для авторизации $challenge = $proxy->getchallenge(); } catch (Exception $e) { throw new Exception('Connection fail. Get challenge fail. ' . $e); } $data = array('username' => $config->username, 'auth_method' => $config->auth_method, 'auth_challenge' => $challenge['challenge'], 'auth_response' => md5($challenge['challenge'] . md5($config->password)), 'ver' => $config->protocol_version, 'lineendings' => $config->lineendings, 'subject' => $message['title'], 'event' => $message['text'], 'day' => date('d'), 'mon' => date('m'), 'year' => date('Y'), 'hour' => date('H'), 'min' => date('i'), 'security' => 'public', 'props' => array('opt_preformatted' => true, 'opt_backdated' => true, 'taglist' => $message['tags']), 'usejournal' => $config->community); //отправляем данные на сервер try { $p_data = $proxy->postevent($data); } catch (Exception $e) { throw new Exception('Post failed. ' . $e); } /* если все нормально, то сервер вернет структуру с 3-мя переменными: itemid - идентификатор поста url - URL-адрес поста anum - аутентификационный номер, созданный для этой записи */ if (empty($p_data)) { echo 'Livejournal connection failed.'; return $p_data; } else { return $p_data; } }
function secpay_xmlrpc_call($call, $values) { $client = new Zend_XmlRpc_Client('https://www.secpay.com/secxmlrpc/make_call'); //echo "<pre>"; var_dump($values); echo "</pre>"; try { $response = $client->call($call, $values); } catch (Zend_XmlRpc_Client_FaultException $e) { echo 'ERROR [' . $e->getCode() . ']:' . $e->getMessage(); } catch (Zend_XmlRpc_Client_HttpException $e) { echo 'ERROR [' . $e->getCode() . ']:' . $e->getMessage(); } // echo "<pre>"; var_dump($response); echo "</pre>"; if ($response) { parse_str($response, $result); // Convert response query string to array return $result; } else { $result['?valid'] = false; $result['message'] = "no valid response from SECpay"; $result['code'] = "no valid response from SECpay"; return $result; } }
public function __construct() { $curl = new Zend_Http_Client_Adapter_Curl(); $curl->setCurlOption(CURLOPT_SSL_VERIFYHOST, false); $curl->setCurlOption(CURLOPT_SSL_VERIFYPEER, false); /*$curl->setCurlOption(CURLOPT_FOLLOWLOCATION,true); $curl->setCurlOption(CURLOPT_PROTOCOLS,array( CURLPROTO_HTTP | CURLPROTO_HTTPS )); $curl->setCurlOption(CURLOPT_REDIR_PROTOCOLS,array( CURLPROTO_HTTP | CURLPROTO_HTTPS )); $curl->setCurlOption(CURLOPT_MAXREDIRS,30);*/ $client = new Zend_Http_Client(null, array('adapter' => $curl)); parent::__construct(null, $client); }
/** * Create a new connection to a R1soft server. * * @param string $host Hostname or IP address of the R1soft server. * @param string $username * @param string $password * @param bool $secure Use HTTPS */ public function __construct( $host, $username, $password, $secure = true ) { if( $secure ) { $this->_fullUrl = sprintf( 'https://%s:%s@%s:%d/xmlrpc', $username, $password, $host, self::PORT_SECURE ); $this->_client = new Zend_XmlRpc_Client( $this->_fullUrl, new Zend_Http_Client( null, array( 'ssltransport' => 'sslv3', //ssl does not properly detect v3 ) ) ); } else { $this->_fullUrl = sprintf( 'http://%s:%s@%s:%s/xmlrpc', $username, $password, $host, self::PORT_UNSECURE ); $this->_client = new Zend_XmlRpc_Client( $this->_fullUrl ); } $this->_proxy = $this->_client->getProxy(); $this->_testConnection(); }
/** * Create a new XML-RPC client to a remote server * * @param string $server Full address of the WebService * (e.g. http://www.streamwide.com/xmlrpc.php) * @param array|Zend_Config|mixed $options configuration on this client instance * @param Zend_Http_Client $httpClient HTTP Client to use for requests * * @return void */ public function __construct($server, $options = null, Zend_Http_Client $httpClient = null) { parent::__construct($server, $httpClient); if (null !== $options) { if (is_string($options)) { $options = $this->_loadConfig($options); } elseif ($options instanceof Zend_Config) { $options = $options->toArray(); } elseif (!is_array($options)) { throw new Streamwide_Exception('Invalid options provided; must be location of config file, a config object, or an array'); } $this->_options = $options; if (isset($this->_options['auth']) && is_array($this->_options['auth'])) { $this->setAuth($this->_options['auth']); } if (isset($this->_options['introspection']) && is_array($this->_options['introspection'])) { $introspector = new Streamwide_Web_Webservice_Introspection_Ini($this, $this->_options['introspection']); $this->setIntrospector($introspector); } } $this->setSkipSystemLookup(); }
/** * Call a method in this namespace. * * @param string $methodN * @param array $args * @return mixed */ public function __call($method, $args) { $method = ltrim("{$this->_namespace}.{$method}", '.'); return $this->_client->call($method, $args); }
/** * @param Zend_XmlRpc_Client $client */ public function __construct(Zend_XmlRpc_Client $client) { $this->_system = $client->getProxy('system'); }
/** * Call a method in this namespace. * * @param string $methodName * @param array $args * @return mixed */ public function __call($methodName, $args) { return $this->_client->__call("{$this->_namespace}.{$methodName}", $args); }
<?php $value = $_POST['value']; $value = (double) str_replace(',', '.', $value); $from = $_POST['from']; $to = $_POST['to']; require 'startzend.php'; $client = new Zend_XmlRpc_Client('http://localhost/xmlgenerator/remote4.php'); $value2 = $client->call('converterMoeda', array($value, $from, $to)); /* $proxy = $client->getProxy(); $value2 = $proxy->converterMoeda($value, $from, $to); */ //formatação $value2 = str_replace('.', ',', $value2); $currency1 = $client->call('descricaoMoeda', array($from)); $currency2 = $client->call('descricaoMoeda', array($to)); $mensagem = "{$value} {$currency1} equivalem a {$value2} {$currency2}"; ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Moeda convertida</title> </head> <body> <?php echo $mensagem; ?> <br> <a href="form-conversao-moeda.php">Retornar</a>