Categories: APIDevelopmentPHP

Empower your website with Wolfram Alpha

Wolfram Alpha‘s computational knowledge engine or answer engine developed by Wolfram Research, which can be consumed as a service as well. Users submit queries and computation requests. Wolfram Alpha then computes answers and relevant visualizations from a knowledge base of curated, structured data that come from other sites and books. 2000 non-commercial API calls per month are free.

They provide a nice set of API Language Libraries to get you started.

  1. <?php  
  2.   $appID = 'PLACE_YOUR_APP_ID_HERE';
  3.  
  4.   if (!$queryIsSet) die();
  5.  
  6.   $qArgs = array();
  7.   if (isset($_REQUEST['assumption']))
  8.     $qArgs['assumption'] = $_REQUEST['assumption'];
  9.  
  10.   // instantiate an engine object with your app id
  11.   $engine = new WolframAlphaEngine( $appID );
  12.  
  13.   // we will construct a basic query to the api with the input 'pi'
  14.   // only the bare minimum will be used
  15.   $response = $engine->getResults( $_REQUEST['q'], $qArgs);
  16.  
  17.   // getResults will send back a WAResponse object
  18.   // this object has a parsed version of the wolfram alpha response
  19.   // as well as the raw xml ($response->rawXML)
  20.  
  21.   // we can check if there was an error from the response object
  22.   if ( $response->isError() ) {
  23. ?>
  24.   <h1>There was an error in the request</h1>
  25.   </body>
  26.   </html>
  27. <?php
  28.     die();
  29.   }
  30. ?>

Developer Portal

Alex

I am a full-stack developer. I love programming,  design and know my way around server architecture as well.  I would never feel complete, with one of these missing. I have a broad range of interests, that’s why I constantly dive into new technologies and expand my knowledge where ever required. Technologies are evolving fast and I enjoy using the latest. Apart from that, I am a peace loving guy who tries to have people around him that think the same.  I truly believe in the principle: “If you help someone, someone will help you, when you need it."

Recent Posts

B&B / Hotel Booking Solutions for WordPress | 2024

BOOKING SOLUTIONS 202x This is my take on a subset of booking, appointment, PMS or… Read More

4 weeks ago

WordPress Cron + WP-CLI + Ntfy

THE GOAL Create a system cron for WordPress, that is accessible and can be easily… Read More

2 months ago

2024 is here and now :)

2024, what's cooking? Slowly getting into the 2024 spirit. 3 projects coming to a close… Read More

4 months ago

2023 ends and whats next !

Short look back at 2023 This has been a busy and interesting year. I am… Read More

4 months ago

cubicFUSION Grid Tweaker – Elementor Grid made easy.

Elementor Pro provides grid containers as an experimental feature. The options provided are limited, when… Read More

5 months ago

Archaeology Travel Booth – Travel Innovation Summit 2023

Archaeology Travel is an online travel guide for people who enjoy exploring the world’s pasts.… Read More

6 months ago