ChaCha PHP API (1.3 KiB, 524 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, 524 hits)