Example #1
0
 /**
  * @method getTemporaryKey
  * @description Connect and Obtain an API key from a vendor key
  * @param string $name - Application Name
  * @param string $user - Username
  * @param string $pass - Password
  * @param string $key - Vendor Key
  * @param string $dbOn - Error Handling On
  * @return bool
  * @throws iSDKException
  */
 public function vendorCon($name, $user, $pass, $key = "", $dbOn = "on")
 {
     $this->debug = $key == 'on' || $key == 'off' || $key == 'kill' || $key == 'throw' ? $key : $dbOn;
     if ($key != "" && $key != "on" && $key != "off" && $key != 'kill' && $key != 'throw') {
         $this->client = new xmlrpc_client("https://{$name}.infusionsoft.com/api/xmlrpc");
         $this->key = $key;
     } else {
         /** @var array $connInfo */
         include 'conn.cfg.php';
         $appLines = $connInfo;
         foreach ($appLines as $appLine) {
             $details[substr($appLine, 0, strpos($appLine, ":"))] = explode(":", $appLine);
         }
         if (!empty($details[$name])) {
             if ($details[$name][2] == "i") {
                 $this->client = new xmlrpc_client("https://" . $details[$name][1] . ".infusionsoft.com/api/xmlrpc");
             } elseif ($details[$name][2] == "m") {
                 $this->client = new xmlrpc_client("https://" . $details[$name][1] . ".mortgageprocrm.com/api/xmlrpc");
             } else {
                 throw new iSDKException("Invalid application name: \"" . $name . "\"");
             }
         } else {
             throw new iSDKException("Application Does Not Exist: \"" . $name . "\"");
         }
         $this->key = $details[$name][3];
     }
     /* Return Raw PHP Types */
     $this->client->return_type = "phpvals";
     /* SSL Certificate Verification */
     $this->client->setSSLVerifyPeer(true);
     $this->client->setCaCertificate((__DIR__ != '__DIR__' ? __DIR__ : dirname(__FILE__)) . '/infusionsoft.pem');
     $encoded_parameters = array(php_xmlrpc_encode($this->key), php_xmlrpc_encode($user), php_xmlrpc_encode(md5($pass)));
     $this->key = $this->methodCaller("DataService.getTemporaryKey", $encoded_parameters);
     $this->encKey = php_xmlrpc_encode($this->key);
     try {
         $connected = $this->dsGetSetting("Application", "enabled");
     } catch (iSDKException $e) {
         throw new iSDKException("Connection Failed");
     }
     return true;
 }