Class smsAPI_HTTPClient

Description

Client smsAPI przez HTTP/HTTPS

Przyklad:

  1.  require_once 'smsapi.php';
  2.  //Instrukcja odpowiedziala za automatyczne wczytywanie class
  3.  spl_autoload_register(array('smsAPI','__autoload'));
  4.  
  5.  try {
  6.  
  7.     $smsapi new smsAPI_HTTPClient('login'md5('password'));
  8.  
  9.     $msg $smsapi->new_sms();
  10.     $msg->add_to'xxxxxxxxx' );
  11.     $msg->message    'test';
  12.     $msg->eco        TRUE;
  13.     $msg->flash        FALSE;
  14.     $msg->test        TRUE;
  15.  
  16.      $result $msg->send();
  17.      var_dump($result);
  18.  
  19.      $smsapi->delete_sms$result[0]->id );
  20.  }
  21.  catch smsAPI_Exception $e )
  22.  {
  23.      echo $e->getMessage();
  24.  }

Located in /smsapi/httpclient.php (line 70)


	
			
Class Constant Summary
Variable Summary
static mixed $call
static array $errors
array $client
int $method
string $url
Method Summary
smsAPI_HTTPClient __construct (string $username, string $password, [int $timeout = 0], [bool $ssl = true], [int $method = self::METHOD_POST])
null delete_sms (string $id)
void get_call ()
stdClass(points,pro,eco) get_points ([bool $details = false])
smsAPI_HTTP_SMS new_sms ([array $params = null])
stdClass(id,points) send_sms (smsAPI_HTTP_SMS $sms)
string server_call (string $params)
Variables
static mixed $call = self::CALL_AUTO (line 379)
  • access: public
static array $errors = array(
0 => 'Nieznany błąd',
11 => 'Zbyt długa lub brak wiadomości',
12 => 'Wiadomość zawiera ponad 160 znaków (gdy użyty parametr &single=1)',
13 => 'Nieprawidłowy numer odbiorcy',
14 => 'Nieprawidłowe pole nadawcy',
17 => 'Nie można wysłać FLASH ze znakami specjalnymi',
18 => 'Nieprawidłowa liczba parametrów',
19 => 'Za dużo wiadomości w jednym odwołaniu (maksymalnie 100)',
20 => 'Nieprawidłowa liczba parametrów IDX',
21 => 'Wiadomość MMS ma za duży rozmiar (maksymalnie 100kB)',
22 => 'Błędny format SMIL',
101 => 'Niepoprawne lub brak danych autoryzacji',
102 => 'Nieprawidłowy login lub hasło',
103 => 'Brak punków dla tego użytkownika',
104 => 'Brak szablonu',
105 => 'Błędny adres IP (włączony filtr IP dla interfejsu API)',
200 => 'Nieudana próba wysłania wiadomości',
300 => 'Nieprawidłowa wartość pola points (przy użyciu pola points jest wymagana wartość 1)',
301 => 'ID wiadomości nie istnieje',
400 => 'Nieprawidłowy ID statusu wiadomości',
999 => 'Wewnętrzny błąd systemu (prosimy zgłosić)'
)
(line 116)

Tablica opisu błędów

  • access: public
array $client (line 92)

Dane klienta

  • access: protected
int $method = null (line 85)

Sposob przesylania danych

string $url = null (line 77)

Url do smsAPI

  • access: protected
Methods
Constructor __construct (line 164)

Inicializacjia

Przyklad:

  1.  try {
  2.  
  3.     $smsapi new smsAPI_HTTPClient('login'md5('password'));
  4.  
  5.  }
  6.  catch smsAPI_Exception $e )
  7.  {
  8.      echo $e->getMessage();
  9.  }

smsAPI_HTTPClient __construct (string $username, string $password, [int $timeout = 0], [bool $ssl = true], [int $method = self::METHOD_POST])
  • string $username: Nazwa użytkownika w serwisie smsAPI
  • string $password: Hasło do Twojego konta w serwisie smsAPI zaszyfrowane w MD5
  • int $timeout: Timeout polączenia
  • bool $ssl: http lub https
  • int $method: Sposób przesyania danych do smsAPI
delete_sms (line 310)

Usuwanie zaplanowanej wiadomości

Przyklad:

  1.  try {
  2.  
  3.     $smsapi new smsAPI_HTTPClient('login'md5('password')true);
  4.  
  5.     $smsapi->delete_sms('1010131304559538088');
  6.  }
  7.  catch smsAPI_Exception $e )
  8.  {
  9.      echo $e->getMessage();
  10.  }

  • throws: smsAPI_Exception
  • access: public
null delete_sms (string $id)
  • string $id: ID wiadomości w systemie smsAPI
get_call (line 381)
  • access: protected
void get_call ()
get_points (line 347)

Sprawdzenie ilości punktów na koncie

Przyklad

  1.  try {
  2.  
  3.     $smsapi new smsAPI_HTTPClient('login'md5('password')true);
  4.  
  5.     $result $smsapi->get_points(true);
  6.  }
  7.  catch smsAPI_Exception $e )
  8.  {
  9.      echo $e->getMessage();
  10.  }

  • access: public
stdClass(points,pro,eco) get_points ([bool $details = false])
  • bool $details
new_sms (line 219)

Utwórz nowa wiadomość

Przyklad:

  1.  try {
  2.  
  3.     $smsapi new smsAPI_HTTPClient('login'md5('password'));
  4.  
  5.     //Tworzenie wiadomości
  6.     $msg $smsapi->new_sms();
  7.     $msg->add_to'xxxxxxxxx''xxxxxxxxx' );
  8.     $msg->message    'test message';
  9.     $msg->eco        TRUE;
  10.     $msg->flash        FALSE;
  11.  
  12.     //Wysłanie wiadomości
  13.     $result $msg->send();
  14.  
  15.      var_dump($result);
  16.     //array
  17.     //  0 =>
  18.     //    object(stdClass)[3]
  19.     //      public 'id' => string '1010131304559538088' (length=19)
  20.     //      public 'points' => string '0.07' (length=1)
  21.  }
  22.  catch smsAPI_Exception $e )
  23.  {
  24.      echo $e->getMessage();
  25.  }

  • access: public
smsAPI_HTTP_SMS new_sms ([array $params = null])
  • array $params
send_sms (line 260)

Wysyłanie pojedynczego SMS'a

Przyklad:

  1.  //Tworzenie wiadomości
  2.  $msg new smsAPI_HTTP_SMS();
  3.  $msg->add_to'xxxxxxxxx''xxxxxxxxx' );
  4.  $msg->message    'test message';
  5.  $msg->eco        TRUE;
  6.  $msg->flash        FALSE;
  7.  
  8.  try {
  9.  
  10.     $smsapi new smsAPI_HTTPClient('login'md5('password'));
  11.  
  12.     //Wysłanie wiadomości
  13.     $result $smsapi->send_sms($msg);
  14.  
  15.      var_dump($result);
  16.     //array
  17.     //  0 =>
  18.     //    object(stdClass)[3]
  19.     //      public 'id' => string '1010131304559538088' (length=19)
  20.     //      public 'points' => string '0.07' (length=1)
  21.  }
  22.  catch smsAPI_Exception $e )
  23.  {
  24.      echo $e->getMessage();
  25.  }

  • throws: smsAPI_Exception
  • access: public
stdClass(id,points) send_sms (smsAPI_HTTP_SMS $sms)
server_call (line 400)

Wywolanie zapytania do strony smsAPI.pl

string server_call (string $params)
  • string $params
Class Constants
CALL_AUTO = 0 (line 375)
CALL_CURL = 2 (line 377)
CALL_FOPEN = 1 (line 376)
METHOD_GET = 0 (line 97)

Przesylania danych metodą GET do smsAPI

METHOD_POST = 1 (line 101)

Przesylania danych metodą POST do smsAPI

Documentation generated on Thu, 27 Jan 2011 16:17:32 +0100 by phpDocumentor 1.4.3