コード例 #1
0
 public function testSettingAndGettingHttpClient()
 {
     $xmlrpcClient = new Zend_XmlRpc_Client('http://foo');
     $httpClient = new Zend_Http_Client('http://foo');
     $this->assertNotSame($httpClient, $xmlrpcClient->getHttpClient());
     $xmlrpcClient->setHttpClient($httpClient);
     $this->assertSame($httpClient, $xmlrpcClient->getHttpClient());
 }
コード例 #2
0
ファイル: Key.php プロジェクト: uibar/peggysgift
 /**
  * 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;
 }
コード例 #3
0
 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;
 }
コード例 #4
0
 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();
 }
コード例 #5
0
 /**
  * @group ZF-4372
  */
 public function testSettingNoHttpClientUriForcesClientToSetUri()
 {
     $baseUri = "http://foo:80";
     $this->httpAdapter = new Zend_Http_Client_Adapter_Test();
     $this->httpClient = new Zend_Http_Client(null, array('adapter' => $this->httpAdapter));
     $this->xmlrpcClient = new Zend_XmlRpc_Client($baseUri);
     $this->xmlrpcClient->setHttpClient($this->httpClient);
     $this->setServerResponseTo(array());
     $this->assertNull($this->xmlrpcClient->getHttpClient()->getUri());
     $this->xmlrpcClient->call("foo");
     $uri = $this->xmlrpcClient->getHttpClient()->getUri(true);
     $this->assertEquals($baseUri, $uri);
 }
コード例 #6
0
ファイル: ClientTest.php プロジェクト: navassouza/zf2
 /**
  * @group ZF-4372
  */
 public function testSettingNoHttpClientUriForcesClientToSetUri()
 {
     $baseUri = 'http://foo:80';
     $this->httpAdapter = new Adapter\Test();
     $this->httpClient = new Http\Client(null, array('adapter' => $this->httpAdapter));
     $this->xmlrpcClient = new Client($baseUri);
     $this->xmlrpcClient->setHttpClient($this->httpClient);
     $this->setServerResponseTo(array());
     $this->assertNull($this->xmlrpcClient->getHttpClient()->getRequest()->getUriString());
     $this->xmlrpcClient->call('foo');
     $uri = $this->xmlrpcClient->getHttpClient()->getUri();
     $this->assertEquals($baseUri, $uri->toString());
 }
コード例 #7
0
 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);
     }
 }
コード例 #8
0
/**
 * 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;
}
コード例 #9
0
ファイル: ClientTest.php プロジェクト: lortnus/zf1
 public function testSettingHttpClientViaContructor()
 {
     $xmlrpcClient = new Zend_XmlRpc_Client('http://foo', $this->httpClient);
     $httpClient = $xmlrpcClient->getHttpClient();
     $this->assertSame($this->httpClient, $httpClient);
 }
コード例 #10
0
 public static function testConnection($params)
 {
     $helper = Mage::helper('advancednewsletter');
     if (!isset($params['apikey'])) {
         throw new AW_Advancednewsletter_Exception($helper->__('Invalid Request. Api key info not found'));
     }
     if (!isset($params['xmlrpc'])) {
         throw new AW_Advancednewsletter_Exception($helper->__('Invalid Request. Xmlrpc info not found'));
     }
     $instance = new self();
     $instance->_keysValues[self::MAILCHIMP_APIKEY] = trim($params['apikey']);
     $instance->_keysValues[self::MAILCHIMP_XMLRPC] = trim($params['xmlrpc']);
     try {
         $client = new Zend_XmlRpc_Client($instance->_connect());
         $client->getHttpClient()->setConfig(array('timeout' => self::REQUEST_TIMEOUT));
         $client->call('chimpChatter', array($instance->_keysValues[self::MAILCHIMP_APIKEY]));
     } catch (Exception $e) {
         throw new AW_Advancednewsletter_Exception($helper->__('Cannot connect to MailChimp'));
     }
 }
コード例 #11
0
 /**
  * Get version of PDF Pro from Server
  */
 public function getMessage()
 {
     if (class_exists('SoapClient')) {
         $client = new PdfProSoapClient($this->decode(self::PDF_PRO_WSDL, '5e6bf967aab429405f5855145e6e0fa7'));
         $client->__setTimeout(1200);
         $session = $client->login($this->decode(self::PDF_PRO_API_USERNAME, '5e6bf967aab429405f5855145e6e0fa7'), $this->decode(self::PDF_PRO_API_PASSWORD, '5e6bf967aab429405f5855145e6e0fa7'));
         $result = $client->call($session, 'pdfpro.getMessage', array());
         $client->endSession($session);
     } else {
         if (class_exists('Zend_XmlRpc_Client')) {
             $client = new Zend_XmlRpc_Client($this->decode(self::PDF_PRO_XMLRPC, '5e6bf967aab429405f5855145e6e0fa7'));
             $client->getHttpClient()->setConfig(array('timeout' => 1200));
             $session = $client->call('login', array($this->decode(self::PDF_PRO_API_USERNAME, '5e6bf967aab429405f5855145e6e0fa7'), $this->decode(self::PDF_PRO_API_PASSWORD, '5e6bf967aab429405f5855145e6e0fa7')));
             $result = $client->call('call', array($session, 'pdfpro.getMessage', array()));
             $client->call('endSession', array($session));
         } else {
             $result = array('success' => false, 'msg' => "Your website does not support for PDF Pro");
         }
     }
     return $result;
 }
コード例 #12
0
ファイル: XmlRpc.php プロジェクト: MajideB/np-gravatar
 /**
  * Sets XML-RPC client.
  *
  * @param Zend_XmlRpc_Client $xmlRpcClient
  * @return NP_Service_Gravatar_XmlRpc
  */
 public function setXmlRpcClient(Zend_XmlRpc_Client $xmlRpcClient)
 {
     //Forcing server uri
     $xmlRpcClient->getHttpClient()->setUri($this->_getServerUri());
     $this->_xmlRpcClient = $xmlRpcClient;
     return $this;
 }
コード例 #13
0
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
require_once 'app/Mage.php';
Mage::init();
define('NUM_ENTITIES', 5000);
define('API_USER', 'apiUser');
define('API_KEY', 'someApiKey123');
define('USE_API', true);
$helper = Mage::helper('api_import/test');
if (USE_API) {
    // Create an API connection. Standard timeout for Zend_Http_Client is 10 seconds, so we must lengthen it.
    $client = new Zend_XmlRpc_Client(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'api/xmlrpc/');
    $client->getHttpClient()->setConfig(array('timeout' => -1));
    $session = $client->call('login', array(API_USER, API_KEY));
}
$entityTypes = array('product' => array('entity' => Mage_ImportExport_Model_Export_Entity_Product::getEntityTypeCode(), 'model' => 'catalog/product', 'types' => array('simple', 'configurable', 'bundle', 'grouped')), 'customer' => array('entity' => Mage_ImportExport_Model_Export_Entity_Customer::getEntityTypeCode(), 'model' => 'customer/customer', 'types' => array('standard')), 'category' => array('entity' => Danslo_ApiImport_Model_Import_Entity_Category::getEntityTypeCode(), 'model' => 'catalog/category', 'types' => array('standard')));
foreach ($entityTypes as $typeName => $entityType) {
    foreach ($entityType['types'] as $subType) {
        // Generation method depends on product type.
        printf('Generating %d %s %ss...' . PHP_EOL, NUM_ENTITIES, $subType, $typeName);
        $entities = $helper->{sprintf('generateRandom%s%s', ucfirst($subType), ucfirst($typeName))}(NUM_ENTITIES);
        // Attempt to import generated products.
        printf('Starting import...' . PHP_EOL);
        $totalTime = microtime(true);
        if (USE_API) {
            try {
                $client->call('call', array($session, 'import.importEntities', array($entities, $entityType['entity'])));
            } catch (Exception $e) {