Exemple de implementare

{

    //REST

    $httpClient = new Zend_Http_Client();

    $httpClient->setUri("https://www.web2sms.ro/send/message");

    $httpClient->setMethod(Zend_Http_Client::POST);

    $username = "TO BE FILL IN AS PROVIDED";

    $apiKey = "TO BE FILL IN AS PROVIDED";

    //$httpClient->setAuth($username, $apiKey);

    $httpClient->setHeaders("Content-Type", "application/json");

    //parametrii metoda

    $crtDate = new Zend_Date();

    $apiKey = "TO BE FILL IN AS PROVIDED";

    $nonce = $crtDate->get(Zend_Date::TIMESTAMP); //data requestului

    $method = "POST";

    $url = "/send/message";

    $data = $crtDate->get(Zend_Date::TIMESTAMP);

    $sender = "";

    $recipient = "0722xxxyyy";

    $message = "MESSAGE TEST ";

    $visibleMessage = "";

    $scheduleDate = $crtDate->get(Zend_Date::TIMESTAMP);

    $validityDate = $crtDate->get(Zend_Date::TIMESTAMP);

    $callbackUrl = '';

    $secret = "TO BE FILL IN AS PROVIDED"; // se va configura la nivel de cont

    $string = $apiKey . $nonce . $method . $url . $sender . $recipient . $message . $visibleMessage . $scheduleDate . $validityDate . $callbackUrl . $secret;

    $signature = hash('sha512', $string);

    $httpClient->setAuth($apiKey, $signature);

    $data = array(

        "apiKey" => $apiKey,

        "sender" => $sender,

        "recipient" => $recipient,

        "message" => $message,

        "scheduleDatetime" => $scheduleDate,

        "validityDatetime" => $validityDate,

        "callbackUrl" => $callbackUrl,

        "userData" => "",

        "visibleMessage" => $visibleMessage,

        "nonce" => $nonce);

    $httpClient->setRawData(Zend_Json::encode($data));

    $httpResponse = $httpClient->request();

    var_dump($httpResponse);

    var_dump($httpResponse->getBody());

    var_dump(json_decode($httpResponse->getBody()));

}

catch (Zend_Http_Client_Exception $e)

{

    var_dump($e->getMessage());

    return array();

}

catch (Zend_Uri_Exception $e)

{

    var_dump($e->getMessage());

    return array();

}


1. Implementare in PHP folosind PEAR SOAP

<?php

require('SOAP/Client.php');

$endpoint = 'http://wsi.web2sms.ro/service.php';

$msg = new SOAP_Client($endpoint);

$method = 'send';

$params = array('phone' => ((string) $_GET[‘phone’]), 'message' => ((string) $_GET[‘message’]) , 'date'=> ((string) $_GET[‘date’]));

$resp = $msg->call($method, $params);

if(is_a($resp, ‘SOAPFault’))

{

    echo “There was an error while tryimg to schedule an SMS!\n”;

    echo “Code: ” . $resp->getMessage() . “\n”;

    echo “Message: ” . $resp->getMessage() . “\n”;

}

else

{

    echo “Sending message succeded. MessageID is ” . $resp;

}

?>


2. Implementare in PHP folosind extensia SOAP

<?php

$soapClient = new SoapClient(“http://wsi.web2sms.ro/service.php?wsdl”);

try

{

    $resp = $soapClient->send((string) $_GET[‘phone’], (string) $_GET[‘message’], (string) $_GET[‘date’]);

    echo “Sending message succeded. MessageID is ” . $resp;

}

catch(Exception $e)

{

    echo “There was an error while tryimg to schedule an SMS!\n”;

    echo “Code: ” . $e->getMessage() . “\n”;

    echo “Message: ” . $e->getMessage() . “\n”;

}

?>


3. Implementare in VB folosind MS SOAP Toolkit

Option Explicit

Sub Main()

    Dim client As Object

    Set client = CreateObject("MSSOAP.SoapClient")

    client.mssoapinit "http://wsi.web2sms.ro/service.php?wsdl", _

                              "SMSServiceService", _

                              "SMSServicePort"

    client.send("0744444444",”hello”,” 2008-03-01T11:11:12.531Z”)

End Sub