Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $q=$_GET['message'];
- $url = "http://en.wikipedia.org/w/api.php?format=xml&action=opensearch&search=".$q."&limit=5&namespace=0";
- trim($url);
- $ch = curl_init();
- curl_setopt($ch,CURLOPT_URL,$url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; he; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8");
- $page = curl_exec($ch);
- $xml = new SimpleXMLElement($page);
- foreach($xml->Section->Item as $it){
- echo "<a href='".$it->Url."'>".$it->Text."</a><br/>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement