PDA

Pogčedajte punu verziju : Clickatell PHP Class


webarto
15. 03. 2011., 22:20
PHP class za clickatell (SMS) API...

http://webarto.com/79/php-clickatell-class

$sms = new SMS;
$x = $sms->send("38761058505", "Hello");
echo $x; // Message SENT!



<?php

/**
* @author Webarto
* @copyright 2011
*/

class SMS{

var $user = "webarto";
var $password = "";
var $api = "";
var $url = "http://api.clickatell.com";

public function send($to, $text){
global $url, $user, $password, $api;
$auth = $this->curl($this->url."/http/auth?user=".$this->user."&password=".$this->password."&api_id=".$this->api);
$auth = explode(":", $auth);
if($auth[0] == "OK"){
$text = trim($text);
$text = urlencode($text);
$text = substr($text, 0, 160);

$status = $this->curl($this->url."/http/sendmsg?user=".$this->user."&password=".$this->password."&api_id=".$this->api."&to=$to&text=$text");
$status = explode(":", $status);
if($status[0] == "ID"){
return "Message SENT!";
}else{
return "Message NOT SENT!";
}
}else{
return "Authentication FAILED!";
}

}

private function curl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
return curl_exec($ch);
curl_close($ch);
}

}

?>


Ima već na njihovom siteu ali meni lično nije bilo nešto korisno... http://www.clickatell.com/developers/php.php