diff --git a/snapporder/config-sample.php b/snapporder/config-sample.php index 3ec7507..3e5a3f8 100644 --- a/snapporder/config-sample.php +++ b/snapporder/config-sample.php @@ -5,4 +5,5 @@ define("REGISTRATION_URL_TIMEOUT_DAYS", 3); define("MAILCHIMP_API_KEY", ""); define("MAILCHIMP_LIST_ID", "004f53d7c6"); + define("TEKSTMELDING_API_KEY", 'qwertyuiop'); ?> diff --git a/snapporder/lib/functions.php b/snapporder/lib/functions.php index c3af290..a1c385d 100644 --- a/snapporder/lib/functions.php +++ b/snapporder/lib/functions.php @@ -588,7 +588,33 @@ function save_activation_form($data) { return true; } + function get_purchase_date($phone, $activation_code) { + $url = "https://tekstmelding.neuf.no/inside-code-purchase-date"; + + $params = array( + 'api_key' => TEKSTMELDING_API_KEY, + 'number' => str_replace('+', '', $phone), + 'activation_code' => $activation_code, + ); + $url .= '?' . http_build_query($params); + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $result = curl_exec($ch); + curl_close($ch); + + $timestamp = clean_timestamp($result); + + if ($timestamp === false) { + return get_purchase_date_legacy($phone, $activation_code); + } + + return $timestamp; +} + +function get_purchase_date_legacy($phone, $activation_code) { global $conn; $gsm = substr($phone, 3); // strip off country code