How to Write Your Own IM Bot in Less Than 5 Minutes


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. // Get all the related keywords from Google Suggest
  3. $u = "http://google.com/complete/search?output=toolbar";
  4. $u = $u . "&q=" . $_REQUEST['msg'];
  5.  
  6. // Using the curl library since dreamhost doesn't allow fopen
  7. $ch = curl_init();
  8. curl_setopt($ch, CURLOPT_URL, $u);
  9. curl_setopt($ch, CURLOPT_HEADER, 0);
  10. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  11.  
  12. curl_close($ch);
  13.  
  14. // Parse the keywords and echo them out to the IM window
  15. $result = $xml->xpath('//@data');
  16. while (list($key, $value) = each($result)) {
  17. echo $value ."<br>";
  18. }
  19. ?>

URL: http://www.labnol.org/internet/tutorial-create-bot-for-gtalk-yahoo-messenger/4354/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.