SennNathan Posted October 27, 2013 Share Posted October 27, 2013 I need to know how to contain the results of this api request in one Div box here is my code. I feel like this should work but when i test it wont work right. <!DOCTYPE html> <?php $request = 'http://api.wolframalpha.com/v2/query?appid=YKAERX-QJJAE7L2G6&input=albert%20einstein&format=html'; $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_URL, $request); $response = curl_exec($curl); curl_close($curl); $blank = ''; $remove = '/]]>/'; $display = preg_replace($remove, $blank, $response); ?> <html> <head> <style> div.ex { width:500px; padding:10px; border:5px solid gray; margin:0px; } </style> </head> <body> <div class="ex"> <?php echo $display ?> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/283332-how-do-contain-the-results-of-this-api-request-in-one-div-box/ Share on other sites More sharing options...
Ch0cu3r Posted October 27, 2013 Share Posted October 27, 2013 (edited) $response contains XML data. You need to process the xml response using simplexml. Edited October 27, 2013 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/283332-how-do-contain-the-results-of-this-api-request-in-one-div-box/#findComment-1455684 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.