sms -> ebt gateway

Euro tracking discussion in English

Moderators: avij, Phaseolus, Fons

Post Reply
SipuliSopuli
Euro-Newbie
Euro-Newbie
Posts: 34
Joined: Thu Jun 30, 2011 12:09 am
Location: Helsinki / Finland
Contact:

sms -> ebt gateway

Post by SipuliSopuli »

Hi! First i want apologize my bad english...

I have done sms -> EBT gateway using EBT api, connectotel and cloudmailin. It works fine (but scandinavian charters like ä or ö does not work (still wondering howto fix this). If there is enough interest about this, i maybe will setup service where you just give ebt username and password and service handles the rest.

So, if you want to set up your own sms -> EBT gateway you will need:
*Server with php and curl
*E-mail address or alias (I recommend an alias)
*Cloudmailin account
*Phone :D

SETUP step 1:-Put into your public_html directory next code, name it something like ebt_iwefhoirhgiorhdiw.php (use some random string to make difficult to guess that)

Code: Select all

<?php
$debug = false;
function logdie($msg) {
	$fp = fopen('ebt_log.txt', 'a');
	fwrite($fp, '[' . date('r') . '] ' . $msg . "\n");
	fclose($fp);
	die();
}


if ($debug) {
$fp = fopen('ebt_debug.txt', 'w');
fwrite($fp, print_r($_REQUEST, true));
fclose($fp);
logdie('Printed $_REQUEST data to ebt_debug.txt');
}

function fgc($url) {
	$ch = curl_init();
 
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_URL, $url);
 
	$data = curl_exec($ch);
	curl_close($ch);
 
	return $data;
}
$user = '<YOUR EBT E-MAIL>';
$pass = '<YOUR EBT PASSWORD>';
$api = 'https://www.eurobilltracker.com/API/api.php?';

if (!$_REQUEST['plain']) logdie("No message specified.");
$msg = explode("\n", $_REQUEST['plain']);
$msg = $msg[0];
list($city, $zip, $country, $denomination, $serial, $shortcode, $comment) = explode(' ', $msg, 7);

$login_result = fgc($api . 'm=login&v=2&my_email=' . urlencode($user) . '&my_password=' . urlencode($pass));
$login_result = json_decode($login_result);
if (!$login_result) logdie("Parsing login result failed.");
$sessionid = $login_result->{'sessionid'};

$insert_result = fgc($api . 'm=insertbills&v=1&PHPSESSID=' . $sessionid . '&city=' . urlencode($city)  . '&zip=' . urlencode($zip) . '&country=' . urlencode($country) . '&serial0=' . urlencode($serial) . '&denomination0=' . urlencode($denomination) . '&shortcode0=' . urlencode($shortcode) . '&comment0=' . urlencode($comment));
$insert_result = json_decode($insert_result);
if (!$insert_result) logdie("Parsing bill insertion result failed.");
logdie("Successfully added bill $city/$zip/$country/$denomination/$serial/$shortcode/$comment");

?>
SETUP step 2:
*create Cloudmailin account https://cloudmailin.com/users/sign_up
*Create new cloudmailin e-mail address and paste for target URL that what you decide before, like my.domain.net/ebt_iwefhoirhgiorhdiw.php and press 'submit'
*Cet your cloudmailin addres and copy it to clipboard

SETUP step 3:
*Create e-mail alias like ebtsms@my.domain.net which directs e-mails to your cloudmailin address

SETUP step 4:
*Test sending note, first up put script into debug mode (so it wont send note information to ebt)

Code: Select all

$debug = false;
*Send sms to connectotel (+447747782320), it should be like " ebtsms@my.domain.net City Postal-code Country Denomination Serial Printer Comment"
*Check cloudmailin message history that alias or e-mail what you set directs e-mails right (if not, make sure that the e-mail address in SMS was right and that you have copied the address correctly from cloudmailin)
*Check file ebt_log.txt, there should be line like "[Tue, 09 Aug 2011 00:53:21 +0300] Printed $_REQUEST data to ebt_debug.txt" (if not, make sure that the URL in cloudmailin is right)
*Check is there file named ebt_debug.txt
*Great, all moving parts who can break is working. Just remove debug mode and submit your first note via sms!

Any comments, bugs, questions and suggestions are welcome :)

EDIT: making manual a bit better
Post Reply

Return to “Site and Euro-tracking Discussion (English)”