Fix broken iwinv SMS driver due to incompatible API URL

iwinv 문자 API가 업데이트되면서 URL이 쥐도새도 모르게 변경되어
기존 사용자는 현행 매뉴얼의 API URL을 사용할 수 없고 (에러 코드 14)
신규 사용자는 기존 라이믹스 드라이버를 사용할 수 없는 현상이 발생하여
어느 쪽 사용자인지 수동으로 선택하도록 변경함.

기존에 API key를 입력해 둔 사용자는 설정 화면 접근시 자동으로
기존 URL이 선택되고, 그렇지 않으면 신규 URL이 선택되도록 함.

카페24에 이어 iwinv까지;;;
국내 업체들은 도대체 REST API 운영에 대한 개념이 있는 건가요?
This commit is contained in:
Kijin Sung 2022-10-11 22:41:09 +09:00
parent 81882e8420
commit 4196d42b06
5 changed files with 44 additions and 4 deletions

View file

@ -8,9 +8,9 @@ namespace Rhymix\Framework\Drivers\SMS;
class iwinv extends Base implements \Rhymix\Framework\Drivers\SMSInterface
{
/**
* API endpoint URL.
* API endpoint URL (fallback if URL is not explicitly configured)
*/
const API_URL = 'https://sms.service.iwinv.kr/send/';
const LEGACY_API_URL = 'https://sms.service.iwinv.kr/send/';
/**
* API specifications.
@ -40,7 +40,7 @@ class iwinv extends Base implements \Rhymix\Framework\Drivers\SMSInterface
/**
* Config keys used by this driver are stored here.
*/
protected static $_required_config = array('api_key', 'api_secret');
protected static $_required_config = array('api_url', 'api_key', 'api_secret');
protected static $_optional_config = array();
/**
@ -54,6 +54,19 @@ class iwinv extends Base implements \Rhymix\Framework\Drivers\SMSInterface
{
return true;
}
/**
* Get the list of API URLs supported by this driver.
*
* @return array
*/
public static function getApiUrls()
{
return array(
'https://sms.bizservice.iwinv.kr/api/send/' => 'sms.bizservice.iwinv.kr',
'https://sms.service.iwinv.kr/send/' => 'sms.service.iwinv.kr',
);
}
/**
* Send a message.
@ -107,12 +120,22 @@ class iwinv extends Base implements \Rhymix\Framework\Drivers\SMSInterface
$data['date'] = gmdate('Y-m-d H:i:s', $message->delay + (3600 * 9));
}
// Set API URL
if (!empty($this->_config['api_url']))
{
$api_url = $this->_config['api_url'];
}
else
{
$api_url = self::LEGACY_API_URL;
}
// We need to use curl because Filehandler::getRemoteResource() doesn't work with this API for some reason.
if (!$curl)
{
$curl = curl_init();
}
curl_setopt($curl, \CURLOPT_URL, self::API_URL);
curl_setopt($curl, \CURLOPT_URL, $api_url);
curl_setopt($curl, \CURLOPT_TIMEOUT, 5);
curl_setopt($curl, \CURLOPT_POST, 1);
curl_setopt($curl, \CURLOPT_RETURNTRANSFER, 1);

View file

@ -92,6 +92,7 @@ class SMS
'name' => $class_name::getName(),
'required' => $class_name::getRequiredConfig(),
'optional' => $class_name::getOptionalConfig(),
'api_urls' => method_exists($class_name, 'getApiUrls') ? $class_name::getApiUrls() : [],
'api_types' => $class_name::getAPITypes(),
'api_spec' => $class_name::getAPISpec(),
);