Last active
August 29, 2015 14:07
-
-
Save sineld/8b6a135ff46231a8925e to your computer and use it in GitHub Desktop.
Şahin Haberleşme SMS API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* Şahin Haberleşme SMS API | |
* wwww.sahinhaberlesme.com.tr | |
* | |
* SMS Gönderim API | |
* | |
* Geliştirme : Sinan Eldem | |
* E-mail : [email protected] | |
* Tel : 0532 486 0614 | |
* Web : http://www.sinaneldem.com.tr | |
* | |
* Ver 1.1 | |
* | |
* 02.10.2014 18:46 | |
* | |
* Lisans: MIT Licence | |
* http://opensource.org/licenses/MIT | |
*/ | |
class SMS | |
{ | |
/** | |
* Kullanıcı adı | |
* @var string | |
*/ | |
private $user = 'KULLANICIADINIZ'; | |
/** | |
* Kullanıcı şifresi | |
* @var string | |
*/ | |
private $pass = 'ŞİFRENİZ'; | |
/** | |
* Alfanumerik başlık | |
* @var string | |
*/ | |
private $title = 'ALFANUMERİK BAŞLIĞINIZ'; | |
/** | |
* API Url | |
* @var string | |
*/ | |
private $url = 'http://api.basscell.com/'; | |
/** | |
* Gönderim zamanı | |
* @var string | |
*/ | |
private $date = 'Y-m-d H:i:s'; | |
/** | |
* Kontör sorgulama | |
* | |
* Örnek Kullanım: | |
* | |
* $sms = new SMS; | |
* echo $counter = $sms->counter(); | |
* | |
* @return integer | |
*/ | |
public function counter() | |
{ | |
$query = [ | |
'islem' => 2, | |
'user' => $this->user, | |
'pass' => $this->pass | |
]; | |
$result = $this->post($query); | |
return str_replace('DONUS|', '', $result); | |
} | |
/** | |
* Başlık sorgulama | |
* | |
* Örnek Kullanım: | |
* | |
* $sms = new SMS; | |
* $title = $sms->title(); | |
* var_dump($title); | |
* | |
* @return array | |
*/ | |
public function title() | |
{ | |
$query = [ | |
'islem' => 3, | |
'user' => $this->user, | |
'pass' => $this->pass | |
]; | |
$result = explode('|', $this->post($query)); | |
return array_filter(explode(';', $result[2])); | |
} | |
/** | |
* Sms gönderme | |
* | |
* Örnek Kullanım: | |
* | |
* $sms = new SMS; | |
* | |
* Tekli gönderme: | |
* $sent = $sms->send(5324860614, 'Örnek mesaj'); | |
* | |
* Çoklu gönderme: | |
* $sent = $sms->send('5324860614,5303061390', 'Örnek mesaj'); | |
* | |
* İleri zamanlı gönderme: | |
* $send = $sms->send(5324860614, 'Örnek mesaj', '2014-10-02 18:45:00'); | |
* | |
* @param $gsm | |
* @param $text | |
* @param $date (optional) | |
* @return bool | |
*/ | |
public function send($gsm, $text, $date = false) | |
{ | |
$query = [ | |
'islem' => $date ? 7 : 1, | |
'user' => $this->user, | |
'pass' => $this->pass, | |
'mesaj' => $text, | |
'numaralar' => $gsm, | |
'baslik' => $this->title, | |
'tarih' => $date ?: date($this->date) | |
]; | |
$result = $this->post($query); | |
$response = explode('|', $result); | |
return $response[1] == 'HATA' ? false : true; | |
} | |
/** | |
* Haberleşmede kullanılacak CURL arabirimi | |
* | |
* @param $query | |
* @return mixed | |
*/ | |
function post($query) | |
{ | |
$curl = curl_init(); | |
curl_setopt($curl, CURLOPT_URL, $this->url); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($curl, CURLOPT_POST, true); | |
curl_setopt($curl, CURLOPT_POSTFIELDS, $query); | |
$result = curl_exec($curl); | |
curl_close($curl); | |
return $result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment