PHP İle SMS Api Hizmeti Kullanımı
PHP İle SMS Api Hizmeti Kullanımı için gerekli örnek kodlama yapısı aşağıdaki gibidir. Bu yapıyı kullanarak İleti Merkezi üzerinden aldığınız kullanıcı bilgileri ile işlem yapabilirsiniz.
Kod İçeriği
<?php function sendRequest($site_name,$send_xml,$header_type) { //die('SITENAME:'.$site_name.'SEND XML:'.$send_xml.'HEADER TYPE '.var_export($header_type,true)); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$site_name); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,$send_xml); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_HTTPHEADER,$header_type); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 120); $result = curl_exec($ch); return $result; } $username = ''; $password = ''; $orgin_name = 'ILETI MRKZI'; $xml = <<<EOS <request> <authentication> <username>{$username}</username> <password>{$password}</password> </authentication> <order> <sender>{$orgin_name}</sender> <sendDateTime>01/05/2013 18:00</sendDateTime> <message> <text>test mesaji api denemesi 1</text> <receipents> <number>123456789</number> </receipents> </message> </order> </request> EOS; $result = sendRequest('http://api.iletimerkezi.com/v1/send-sms',$xml,array('Content-Type: text/xml')); die('<pre>'.var_export($result,1).'</pre>'); //Donen xml degerini sisteminizde parse etmek icin //http://www.lalit.org/lab/convert-xml-to-array-in-php-xml2array/ //adresindeki kutuphaneyi oneririz ?>