By brandon.corbin on Tuesday February 16th, 2010

  ChaCha PHP API (1.3 KiB, 347 hits)

ChaCha has finally released an API for their Question and Answer service (documentation here). Personally, I have been waiting for years to get my hands on this data, and today I am happy to share this PHP Class for accessing both questions/answers and trending topics. You will need to register for an API, but the process is quick and painless.

Example One

Dump the contents of both the Trends and a Question

$capi = ChaChaAPI('your-key-here');
$answer = $capi->ask("Who is Brandon Corbin?");
$trends = $capi->getTrends();

var_dump($trends);
var_dump($answer);

Example Two:

Output the just the Answer of your question.

$capi = ChaChaAPI('your-key-here');
echo $capi->ask("Who is Brandon Corbin")->qvpResults[0]->answer->answer

GPL. This is offered AS IS, with no guarantees. In fact it might turn your webserver in to a brain eating Zombie that will attack you in your sleep.

  ChaCha PHP API (1.3 KiB, 347 hits)

4 Responses to “ChaCha API with PHP”

  1. Questions? Ask them in the comments!

  2. Nice little tool, Brandon. Thanks for sharing.

  3. My question is: can we use this to answer questions without actually being on the chacha site? I have being looking for someway to do that for the longest time.

Leave a Reply

← By brandon.corbin

I am Brandon Corbin, a web entrepreneur with a background in advertising and design. For over a decade I have applied my passion for user experience, marketing and software design to industries like: radio, real estate, pharmaceuticals, recruiting and eCommerce.