What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Request] Simple Script to send message to PHP Script

Pages: (2): « First [ 1 ] 2 » Last »
1 votes - 5 average   [Request] Simple Script to send message to PHP Script
Author: Message:
Dempsey
Scripting Contest Winner
*****

Avatar
http://AdamDempsey.net

Posts: 2395
Reputation: 53
37 / Male / Flag
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 :)
SoundPacks   -   Scripts   -   Skins

that's not a bug, thats an unexpected feature
03-06-2008 03:40 PM
Profile E-Mail PM Web Find Quote Report
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
31 / Male / Flag
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);
      }
    }
  }
}
4 8 15 16 23 42
03-06-2008 04:58 PM
Profile E-Mail PM Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
35 / Male / Flag
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.
[Image: markee.png]
03-06-2008 09:45 PM
Profile PM Find Quote Report
Dempsey
Scripting Contest Winner
*****

Avatar
http://AdamDempsey.net

Posts: 2395
Reputation: 53
37 / Male / Flag
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
SoundPacks   -   Scripts   -   Skins

that's not a bug, thats an unexpected feature
03-07-2008 11:43 AM
Profile E-Mail PM Web Find Quote Report
Richy
Junior Member
**

Avatar

Posts: 16
35 / Male / Flag
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
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
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);
}
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
03-07-2008 05:49 PM
Profile E-Mail PM Web Find Quote Report
Richy
Junior Member
**

Avatar

Posts: 16
35 / Male / Flag
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
Profile E-Mail PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
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" :zippy:
03-08-2008 11:08 AM
Profile PM Find Quote Report
Richy
Junior Member
**

Avatar

Posts: 16
35 / Male / Flag
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
Profile E-Mail PM Find Quote Report
effection
Full Member
***

Destroy The Runner

Posts: 135
Reputation: 4
– / Male / Flag
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
Profile E-Mail PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On