[Request] Simple Script to send message to PHP Script |
Author: |
Message: |
Dempsey
Scripting Contest Winner
http://AdamDempsey.net
Posts: 2395 Reputation: 53
38 / /
Joined: Jul 2003
|
O.P. [Request] Simple Script to send message to PHP Script
Can someone make me a simple script called AwaySMS which when my status is set to away, it will use xmlhttp to send incoming messages to a php script, which I will then use to SMS me the message?
Ideally I'd be able to either blacklist or whitelist users I do / don't want to wasts sms credits on.
I know its a simple script but I'm very lazy!
Thanks if anyone makes it
|
|
03-06-2008 03:40 PM |
|
|
vikke
Senior Member
Posts: 900 Reputation: 28
31 / /
Joined: May 2006
|
RE: [Request] Simple Script to send message to PHP Script
Sorry, but I think this should work (not tested, I'm on Linux).
code: var whitelist = Array();
whitelist[0] = "asdf@asdf.com";
// Add more here!
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
if(Messenger.MyStatus == STATUS_AWAY || Messenger.MyStatus == STATUS_IDLE)
{
for each(email in whitelist)
{
// Multi-conversations won't work yet.
if(email == ChatWnd.Contacts[0].Email)
{
SendToPHP(email, Message);
}
}
}
}
|
|
03-06-2008 04:58 PM |
|
|
markee
Veteran Member
Posts: 1622 Reputation: 50
36 / /
Joined: Jan 2006
|
RE: [Request] Simple Script to send message to PHP Script
code: function SendToPHP(email,msg){
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
with(xmlhttp){
setRequestHeader("email",email);
setRequestHeader("message",msg);
onreadystatechange = function(){if(readyState==4 && status!=200) Debug.Trace("ERROR!\n\n email: "+email+"\n\n message"+msg);};
open("POST", /*make sure you defile this variable*/ url,true);
send(null);
}
}
This should post the information to the PHP (should help to eliminate problems with special characters in case you were just adding it to a parameter in the URL for a GET).
This just continues on from vikke's code, you can always just add it in that other function if you really would prefer....
EDIT: not sure if the with will work over the local function and I can't test it while I'm at uni....
This post was edited on 03-06-2008 at 09:47 PM by markee.
|
|
03-06-2008 09:45 PM |
|
|
Dempsey
Scripting Contest Winner
http://AdamDempsey.net
Posts: 2395 Reputation: 53
38 / /
Joined: Jul 2003
|
O.P. RE: [Request] Simple Script to send message to PHP Script
Thanks vikke and markee, got it sorted now
I might actually work on making this public so other people can use it too. Just trying to think of a way to send a message back too
|
|
03-07-2008 11:43 AM |
|
|
Richy
Junior Member
Posts: 16
36 / /
Joined: Feb 2008
|
RE: [Request] Simple Script to send message to PHP Script
Hello everybody,
I am looking for similar script. I created a new script with your these codes;
code: function SendToPHP(email,msg){
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
with(xmlhttp){
setRequestHeader("email",email);
setRequestHeader("message",msg);
onreadystatechange = function(){if(readyState==4 && status!=200) Debug.Trace("ERROR!\n\n email: "+email+"\n\n message"+msg);};
open("POST", "http://test.com/sendtophp.com", true);
send(null);
}
}
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
// Multi-conversations won't work yet.
if(email == ChatWnd.Contacts[0].Email)
{
SendToPHP(email, Message);
}
}
I don't want to create a white list or black list. I want to send all data to php. But when someone sends me a message, this script gives an error in debugging window:
Script is now loaded and ready
Function called: OnEvent_ChatWndReceiveMessage
Error: 'email' is undefined (code: -2146823279)
File: msn.js. Line: 17.
Function OnEvent_ChatWndReceiveMessage returned an error. Code: -2147352567
Can anybody help me?
This post was edited on 03-07-2008 at 03:44 PM by Richy.
|
|
03-07-2008 03:43 PM |
|
|
Matti
Elite Member
Script Developer and Helper
Posts: 1646 Reputation: 39
32 / /
Joined: Apr 2004
|
RE: [Request] Simple Script to send message to PHP Script
Quite easy in fact. You left the check for the "email", which was used as iterator variable for the white list.
code: function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
SendToPHP(ChatWnd.Contacts[0].Email, Message);
}
|
|
03-07-2008 05:49 PM |
|
|
Richy
Junior Member
Posts: 16
36 / /
Joined: Feb 2008
|
RE: [Request] Simple Script to send message to PHP Script
Thank you Mattike,
But I have still an error.
code: function SendToPHP(email,msg){
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
with(xmlhttp){
setRequestHeader("email",email);
setRequestHeader("message",msg);
onreadystatechange = function(){if(readyState==4 && status!=200) Debug.Trace("ERROR!\n\n email: "+email+"\n\n message"+msg);};
open("POST", "http://test.com/sendtophp.php", true);
send(null);
}
}
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
SendToPHP(ChatWnd.Contacts[0].Email, Message);
}
The error;
Script is now loaded and ready
Function called: OnEvent_ChatWndReceiveMessage
Error: 'Contacts.0.Email' is null or not an object (code: -2146823281)
File: msn.js. Line: 16.
Function OnEvent_ChatWndReceiveMessage returned an error. Code: -2147352567
Also, I writed this PHP script. Is everything ok?
code: <?
@setlocale(LC_ALL, 'turkish');
$link = mysql_connect('mysql.***.com', '***', '***');
if (!$link) {
die("Problem");
}
mysql_select_db("moda", $link)
or die ("Problem!");
@mysql_query("SET NAMES 'latin5'");
if (isset($_POST["email"]) OR isset($_POST["message"])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
mysql_query("
INSERT INTO logs
(`user`,`in`,`ip`)
VALUES
(
'{$_POST["email"]}',
'{$_POST["message"]}',
'{$ip}'
)
");
}
mysql_close($link);
?>
This post was edited on 03-08-2008 at 08:55 AM by Richy.
|
|
03-08-2008 08:51 AM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: [Request] Simple Script to send message to PHP Script
code: function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
for(var e = new Enumerator(ChatWnd.Contacts); !e.atEnd(); e.moveNext()){
SendToPHP(e.item().Email, Message);
break;
}
}
That'll work. Although I'm sure Mattike's code should work. Might be because it's a collection and not a proper array. Someone clarify that for me?
This post was edited on 03-08-2008 at 11:12 AM by Spunky.
<Eljay> "Problems encountered: shit blew up"
|
|
03-08-2008 11:08 AM |
|
|
Richy
Junior Member
Posts: 16
36 / /
Joined: Feb 2008
|
RE: [Request] Simple Script to send message to PHP Script
Now, it gives;
Function called: OnEvent_ChatWndReceiveMessage
Error: Unspecified error
(code: -2147467259)
File: msn.js. Line: 4.
Function OnEvent_ChatWndReceiveMessage returned an error. Code: -2147352567
I'm using MSN 8.5. And, the latest version of Messenger Plus.
This post was edited on 03-12-2008 at 04:15 PM by Richy.
|
|
03-08-2008 11:17 AM |
|
|
effection
Full Member
Destroy The Runner
Posts: 135 Reputation: 4
– / /
Joined: Sep 2006
|
RE: [Request] Simple Script to send message to PHP Script
post your code please il have a look
|
|
03-14-2008 08:03 PM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|