X   Сообщение сайта
(Сообщение закроется через 3 секунды)



 

Здравствуйте, гость (

| Вход | Регистрация )

Открыть тему
Тема закрыта
> SMS API
Nazim
Nazim
Topic Starter сообщение 31.1.2015, 0:24; Ответить: Nazim
Сообщение #1


Хелп над проверить api example.php
[PHP]<?php
include_once('class.BulkSms.php');


$bulkSms = new BulkSms( 'user', 'user', '351' );

if( $bulkSms->sendSms("test message", "961234567") ){
echo "Message Sent: <br>
Status Code: ".$bulkSms->status_code ." <br>
Status Description: ".$bulkSms->status_description."<br><br>";
}
else{
echo "Error Sending Message: <br>
Status Code: ".$bulkSms->status_code ." <br>
Status Description: ".$bulkSms->status_description."<br><br>";
}
echo "Credits Remaining: ".$bulkSms->getCredits();

?>[/PHP]




bulksms_api_2.php
[PHP]<?php
/************************************************************\
*
* BulkSms version 0.9, modified 11-Dez-08
* By Nuno Chaves
* nunochave@sapo.pt
*
* Class for sending messages from http://bulksms.vsms.net/
* uses bulksms Version 2.0 API reference.
*
/************************************************************\
* This library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software
* Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*/

class BulkSms{

private $host;
private $user;
private $pass;
private $countryCode;
private $port;

public $status_code;
public $status_description;
public $smsQuote;


function BulkSms( $user, $pass, $countryCode='351', $host='bulksms.vsms.net', $port='5567' ){
$this->host = $host;
$this->user = $user;
$this->pass = $pass;
$this->countryCode = $countryCode;
$this->port = $port;
}


/*
* $msg - message to send
* $mobilePhone - destination phone without the international code
* $quote - if true stores sms send cost in credits on class public var smsQuote
*
* the message is encoded with urlencode to be sent. see http://en.wikipedia.org/wiki/Short_message_service#GSM for chars supported.
*
* send URL => http://bulksms.vsms.net:5567/eapi/submissi...sdn=12345678901
*
* ERROR CODES
* 0: In progress (a normal message submission, with no error encountered so far).
* 1: Scheduled.
* 22: Internal fatal error
* 23: Authentication failure
* 24: Data validation failed
* 25: You do not have sufficient credits
* 26: Upstream credits not available
* 27: You have exceeded your daily quota
* 28: Upstream quota exceeded
* 40: Temporarily unavailable
*
* */
function sendSms( $msg, $mobilePhone, $quote=false ){

$this->status_code = 0;
$this->smsQuote = 0;
$this->status_description = "";

$ch = curl_init();

if( !$quote )
curl_setopt($ch, CURLOPT_URL, 'http://'.$this->host.':'.$this->port.'/eapi/submission/send_sms/2/2.0');

else curl_setopt($ch, CURLOPT_URL, 'http://'.$this->host.':'.$this->port.'/eapi/submission/quote_sms/2/2.0');

curl_setopt ($ch, CURLOPT_POST, 1);
$post_fields = 'username='.$this->user.'&password='.$this->pass.'&message='.urlencode($msg).'&msisdn='.$this->countryCode.$mobilePhone;
curl_setopt ($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response_string = curl_exec($ch);
curl_close($ch);

$arrResponse = explode('|',$response_string);

if( !$quote ){
$this->status_code = $arrResponse[0];
$this->status_description = $arrResponse[1];
}
else{
$this->status_code = $arrResponse[0];
$this->smsQuote = $arrResponse[2];
}
if( $this->status_code == 0 ) return true;
else return false;
}


// returns float value with sms send cost in credits
function getSmsQuote( $msg, $mobilePhone ){
if( $this->sendSms( $msg, $mobilePhone, true ) )
return $this->smsQuote;

else return 0;
}


function getCredits(){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://'.$this->host.':'.$this->port.'/eapi/user/get_credits/1/1.1');
curl_setopt ($ch, CURLOPT_POST, 1);
$post_fields = 'username='.$this->user.'&password='.$this->pass;
curl_setopt ($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response_string = curl_exec($ch);
curl_close($ch);

$arrResponse = explode('|',$response_string);

if( $arrResponse[0] == 0 ) return $arrResponse[1];
else return -1;
}

}
?>[/PHP]
0
Вернуться в начало страницы
 
Ответить с цитированием данного сообщения
Arks
Arks
сообщение 31.1.2015, 17:21; Ответить: Arks
Сообщение #2


(Nazim @ 31.1.2015, 02:24) *
* BulkSms version 0.9, modified 11-Dez-08

я бы не стал такое проверять...

Замечание модератора:
Эта тема была закрыта автоматически ввиду отсутствия активности в ней на протяжении 100+ дней.
Если Вы считаете ее актуальной и хотите оставить сообщение, то воспользуйтесь кнопкой
или обратитесь к любому из модераторов.
Вернуться в начало страницы
 
Ответить с цитированием данного сообщения
Открыть тему
Тема закрыта
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0


Свернуть

> Похожие темы

  Тема Ответов Автор Просмотров Последний ответ
Открытая тема (нет новых ответов) ✅ sms.chekons.com - ⭐ Сервис для получения SMS на реальные номера USA "Non-VoIP, безлим SMS, API" ⭐
Сервис для получения SMS на реальные номера USA
10 Chekon 3578 24.3.2024, 14:15
автор: Chekon
Открытая тема (нет новых ответов) ⭐⭐⭐ Google Voice | Gmail - OLD аккаунты "SMS и звонки" ⭐⭐⭐
12 Chekon 3808 24.3.2024, 13:56
автор: Chekon
Открытая тема (нет новых ответов) ✅USMobileSMSBot - 🤖Telegram Bot (24/7) SMS Верификации на реальные номера USA 🔥Одноразовая и долгосрочная аренда🔥 Non-VoIP.
Верификации на реальные номера USA
12 Chekon 3134 23.3.2024, 12:34
автор: Chekon
Открытая тема (нет новых ответов) Интеграция спортивных данных API. Коэффициенты БК, Live результаты
14 yaroslav89 6625 13.3.2024, 23:16
автор: spoyer_ru
Открытая тема (нет новых ответов) Продажа аккаунтов ChatGPT (OpenAI / DALL·E) с балансом API KEY 5$
10 Gagablik 2873 13.2.2024, 0:05
автор: malamut


 



RSS Текстовая версия Сейчас: 28.3.2024, 16:22
Дизайн