Making Post Request to icq.com

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wsjb78
Forum Newbie
Posts: 4
Joined: Sun Jun 22, 2003 5:52 pm
Contact:

Making Post Request to icq.com

Post by wsjb78 »

What I want is that automatically a web pager message is sent to my icq when a certain page is being accessed (e.g. a 404 page when Search Engines try to access a non- existing site).

The PHP part is what I've written, the HTML part is copy and paste from the original icq web pager interface.

Code: Select all

<?

function PostToHost($host, $path, $referer, $data_to_send) {
	$fp = fsockopen($host, 80);
	printf("Open!\n");
	fputs($fp, "POST $path HTTP/1.1\n");
	fputs($fp, "Host: $host\n");
	fputs($fp, "Referer: $referer\n");
	fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
	fputs($fp, "Content-length: ". strlen($data_to_send) ."\n");
	fputs($fp, "Connection: close\n\n");
	fputs($fp, "$data_to_send\n");
	printf("Sent!\n");
	while(!feof($fp)) {
		$res .= fgets($fp, 128);
	}
	printf("Done!\n");
	fclose($fp);

	return $res;
}

//if(eregi("(googlebot|scooter|fast|find|slurp|crawl|search|seek|spider)", $HTTP_USER_AGENT)) {

	$data = "from=SE-Bots&body=404_while_SE-Bots&to=1128681";

	printf("Go!\n");
	$x = PostToHost(
	    "www.icq.com",
	    "/scripts/WWPMsg.dll",
	    "http://www.wsjb78.com/icqpanel.php",
	    $data
	);

//}

?>



<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE></TITLE>
</HEAD><BODY>
Official copy'n'paste web pager panel:<br>
<form action="http://wwp.icq.com/scripts/WWPMsg.dll" method="post">
<center>
<table border="2" cellpadding="1" cellspacing="1"><tr><td>
<table cellpadding="0" cellspacing="0" border="0" bgcolor="silver">
<tr>
<td align="center" nowrap colspan="2" bgcolor="#0000a0">
<font size="-1" face="arial" color="white"><b>The ICQ Online-Message Panel</b></font></td>
</tr>
<tr>
<td align="center"><font size="-2" face="ms sans serif" color="black"><b>Sender Name</b> (optional):</font><br><input type="text" name="from" value="" size=15 maxlength=40 onfocus="this.select()"></td>
<td align="center"><font size="-2" face="ms sans serif" color="black"><b>Sender EMail</b> (optional):</font><br><input type="text" name="fromemail" value="" size=15 maxlength=40 onfocus="this.select()">
<input type="hidden" name="subject" value="From Your Web Page"></td>
</tr>
<tr>
<td align="center" colspan="2"><font size="-2" face="ms sans serif" color="black">Message:</font><br>
<textarea name="body" rows="3" cols="30" wrap="Virtual"></textarea><br></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="hidden" name="to" value="1128681">
<input type="submit" name="Send" value="Send Message">&nbsp;&nbsp;
<input type="reset" value="Clear">
</td>
</tr>
<tr>
<td align="center" nowrap colspan="2">
<font size="-2" face="ms sans serif">&nbsp;<br><a href="http://public.icq.com/public/panels/messagepanel/links/wwp.html?1128681">My Unified Messaging Center</a>&nbsp;&nbsp;
<a href="http://public.icq.com/public/panels/messagepanel/links/icq.html">What is ICQ, Download</a>
<br><a href="http://public.icq.com/public/panels/messagepanel/links/messagepanel.html">Install this Online Message Panel on your homepage</a></font></td>
</tr>
</table>
</td></tr></table>
<font face="MS Sans Serif" size="-2"><a href="/public/panels/messagepanel/links/messagepanel.html">This site is powered by the ICQ Online-Message Panel</a> &copy; 1999 ICQ Inc. All Rights Reserved.<br>Use of the ICQ Online-Message Panel is subject to the <a href="http://public.icq.com/public/panels/webcast/links/legal.html">Terms of Service</font></form>
</center>

</BODY></HTML>
The web page form from ICQ works but not my PHP attempt.

1128681 is my ICQ number and the script is like that on http://www.wsjb78.com/ icqpanel.php

wsjb78
hedge
Forum Contributor
Posts: 234
Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada

Post by hedge »

I would suggest trying http 1.0, I believe you have to be able to handle a 'chunked' response with 1.1. Also I notice that you are using \n as your delimiter, I usually use \r\n.

This is a link to some code that works for me (at the bottom), my function 'httpSimulateFormSubmit' looks very similar to your code except for a few subtle differences.

Also, are you sure you don't have to pass any credentials along? the example here logs into an asp site, gets the session cookie and then passes it along on the next requests. Are you sure you don't have to do something similar?

viewtopic.php?t=7063
wsjb78
Forum Newbie
Posts: 4
Joined: Sun Jun 22, 2003 5:52 pm
Contact:

Post by wsjb78 »

I'll have a look at your code there. What I have to add is that the host needs to be wwp.icq.com . That was a mistake from my part but it's still not working with that change!
Post Reply