Hey guys, I have a php script that I wrote and it creates short url links. It does so quite nicely, and the page is all shiny with jQuery ajax and loads of functionality and everything is great. Now I'm just wondering, where would I go to start to be able to make the script take data from somewhere other than the input form? Lets say I write an irc script to create short urls from within the irc client? How would I make it so that a link and expiration data and shorturl tag (the 3 paramaters for the url) get sent to the php script, and make it listen for the php response?
Right now the script takes the data from the form, creates the short url link and puts the 3 paramaters (expiration date, short tag, and url) in a mysql table. Then with .htaccess when you go to op2rules.net/shorttag it does a regex to turn the tag at the end to a $_GET variable, and then replaces the header with the matching url from the mysql table.
So again, what I want to do is be able to access all of this functionality from a program or a script that would run within IRC.
Thanks a load!
PHP I/O from IRC?
Started by op2rules, Jul 26 2010 08:42 AM
4 replies to this topic
#1
Posted 26 July 2010 - 08:42 AM
|
|
|
#2
Posted 26 July 2010 - 01:45 PM
You need to use PHP Sockets and the IRC protocol as documented in the RFC 1459.
#3
Posted 26 July 2010 - 02:06 PM
I believe there is a great irc class in the pear library.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
I study Information Systems at Karlstad University when I'm not on CodeCall
#4
Posted 26 July 2010 - 05:18 PM
Unless you're all using a client compatible with custom scripting, you need to create a bot to handle the communication, here is an extensively simple example:
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect($socket, $ip, $port);
sleep(1);
socket_write($socket, "(user ident code here)");
while ($read = socket_read($socket, 2048)) {
//do something with socket data
socket_write($socket, "/msg $user " . shortenUrl($read)) . "\n";
}
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
#5
Posted 26 July 2010 - 06:02 PM
Nonono guys thats not what I meant I don't want PHP to be the one connecting to IRC. I solved the problem by making a new file with a similar copy to the script, except this one used $_GET for the variables and then the python irc bot uses urlopen(sendurl).read() with the urlopen import from urllib to use the url to do what I want it to. That is assigned to a variable and the php echo output is then displayed on IRC.
Thanks anyways though!
Thanks anyways though!


Sign In
Create Account

Back to top









