snakeccc
Junior Member
- Jan 23, 2012
- 125
- 113
I was coding somethng for my personal project, and now i need create automaticaly Fortumo script for every user on registracion.
So this is SMS script that i need to create unique for every user..Unique param for every user is Fortumo Api Secret code. I'am noob now when i need to do that
Every good replay can help. Thanks
[/COLOR]
So this is SMS script that i need to create unique for every user..Unique param for every user is Fortumo Api Secret code. I'am noob now when i need to do that
Code:
[COLOR=#ff0000]<?php[/COLOR]
[COLOR=#ff8c00]//set true if you want to use script for billing reports
//first you need to enable them in your account[/COLOR]
$billing_reports_enabled = [COLOR=#008000]false[/COLOR];
[COLOR=#ff8c00]// check that the request comes from Fortumo server[/COLOR]
[COLOR=#008000]if[/COLOR]([COLOR=#0000cd]!in_array[/COLOR]([COLOR=#40e0d0]$_SERVER[/COLOR][[COLOR=#ff0000]'REMOTE_ADDR'[/COLOR]],
[COLOR=#0000cd]array[/COLOR]([COLOR=#ff0000]'81.20.151.38', '81.20.148.122', '79.125.125.1', '209.20.83.207'[/COLOR]))) {
[COLOR=#0000cd]header[/COLOR]([COLOR=#ff0000]"HTTP/1.0 403 Forbidden"[/COLOR]);
[COLOR=#0000cd]die[/COLOR]([COLOR=#ff0000]"Error: Unknown IP"[/COLOR]);
}
[COLOR=#ff8c00]// check the signature[/COLOR]
$secret =[COLOR=#ff0000] ' '[/COLOR];[COLOR=#ff8c00] // secret between '' [/COLOR][COLOR=#fff0f5]<------ UNIQUE FOR EVERY USER![/COLOR]
[COLOR=#008000]if[/COLOR]([COLOR=#0000cd]empty[/COLOR]($secret) || !check_signature($_GET, $secret)) {
[COLOR=#0000cd]header[/COLOR]([COLOR=#ff0000]"HTTP/1.0 404 Not Found"[/COLOR]);
[COLOR=#0000cd]die[/COLOR]([COLOR=#ff0000]"Error: Invalid signature"[/COLOR]);
}
$sender = [COLOR=#40e0d0]$_GET[/COLOR][[COLOR=#ff0000]'sender'[/COLOR]];
$message = [COLOR=#40e0d0]$_GET[/COLOR][[COLOR=#ff0000]'message'[/COLOR]];
$message_id = [COLOR=#40e0d0]$_GET[/COLOR][[COLOR=#ff0000]'message_id'[/COLOR]];//unique id
[COLOR=#ff8c00]//hint:use message_id to log your messages
//additional parameters: country, price, currency, operator, keyword, shortcode
// do something with $sender and $message[/COLOR]
$reply =[COLOR=#ff0000] "Thank you $sender for sending $message"[/COLOR];
[COLOR=#ff8c00]// print out the reply[/COLOR]
[COLOR=#0000cd]echo[/COLOR]($reply);
[COLOR=#ff8c00]//customize this according to your needs[/COLOR]
[COLOR=#008000]if[/COLOR]($billing_reports_enabled
[COLOR=#0000cd]&& preg_match[/COLOR]([COLOR=#ff0000]"/Failed/i"[/COLOR],[COLOR=#40e0d0] $_GET[/COLOR][[COLOR=#ff0000]'status'[/COLOR]])
[COLOR=#0000cd]&& preg_match[/COLOR]([COLOR=#ff0000]"/MT/i"[/COLOR], [COLOR=#40e0d0]$_GET[/COLOR][[COLOR=#ff0000]'billing_type'[/COLOR]])) {
[COLOR=#ff8c00]// find message by $_GET['message_id'] and suspend it[/COLOR]
}
[COLOR=#0000cd]function[/COLOR] check_signature($params_array, $secret) {
[COLOR=#0000cd]ksort[/COLOR]($params_array);
$str = [COLOR=#ff0000]''[/COLOR];
[COLOR=#008000]foreach [/COLOR]($params_array [COLOR=#008000]as[/COLOR] $k[COLOR=#0000cd]=>[/COLOR]$v) {
[COLOR=#008000]if[/COLOR]($k != [COLOR=#ff0000]'sig'[/COLOR]) {
$str .= "$k=$v";
}
}
$str .= $secret;
$signature = [COLOR=#0000cd]md5[/COLOR]($str);
[COLOR=#008000]return[/COLOR] ($params_array['sig'] [COLOR=#0000cd]==[/COLOR] $signature);
}
[COLOR=#ff0000]?>
Last edited by a moderator: