mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-23 04:56:02 +03:00
Added ability to disable SSL for testing against a Postbin or other endpoint.
This commit is contained in:
parent
7323f28f3a
commit
72c10a5428
@ -20,9 +20,9 @@ class RestClient{
|
|||||||
private $apiKey;
|
private $apiKey;
|
||||||
protected $mgClient;
|
protected $mgClient;
|
||||||
|
|
||||||
public function __construct($apiKey, $apiEndpoint, $apiVersion){
|
public function __construct($apiKey, $apiEndpoint, $apiVersion, $ssl){
|
||||||
$this->apiKey = $apiKey;
|
$this->apiKey = $apiKey;
|
||||||
$this->mgClient = new Guzzle('https://' . $apiEndpoint . '/' . $apiVersion . '/');
|
$this->mgClient = new Guzzle($this->generateEndpoint($apiEndpoint, $apiVersion, $ssl));
|
||||||
$this->mgClient->setDefaultOption('curl.options', array('CURLOPT_FORBID_REUSE' => true));
|
$this->mgClient->setDefaultOption('curl.options', array('CURLOPT_FORBID_REUSE' => true));
|
||||||
$this->mgClient->setDefaultOption('auth', array (API_USER, $this->apiKey));
|
$this->mgClient->setDefaultOption('auth', array (API_USER, $this->apiKey));
|
||||||
$this->mgClient->setDefaultOption('exceptions', false);
|
$this->mgClient->setDefaultOption('exceptions', false);
|
||||||
@ -97,6 +97,15 @@ class RestClient{
|
|||||||
$result->http_response_code = $httpResponseCode;
|
$result->http_response_code = $httpResponseCode;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function generateEndpoint($apiEndpoint, $apiVersion, $ssl){
|
||||||
|
if(!$ssl){
|
||||||
|
return "http://" . $apiEndpoint . "/" . $apiVersion . "/";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return "https://" . $apiEndpoint . "/" . $apiVersion . "/";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@ -22,8 +22,8 @@ class Mailgun{
|
|||||||
protected $workingDomain;
|
protected $workingDomain;
|
||||||
protected $restClient;
|
protected $restClient;
|
||||||
|
|
||||||
public function __construct($apiKey = null, $apiEndpoint = "api.mailgun.net", $apiVersion = "v2"){
|
public function __construct($apiKey = null, $apiEndpoint = "api.mailgun.net", $apiVersion = "v2", $ssl = true){
|
||||||
$this->restClient = new RestClient($apiKey, $apiEndpoint, $apiVersion);
|
$this->restClient = new RestClient($apiKey, $apiEndpoint, $apiVersion, $ssl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendMessage($workingDomain, $postData, $postFiles = array()){
|
public function sendMessage($workingDomain, $postData, $postFiles = array()){
|
||||||
|
Loading…
Reference in New Issue
Block a user