Question

$bot = file_get_contents("http://answers.yahooapis.com/AnswersService/V1/questionSearch?appid=API_KEY&query=".$q1."");
echo $bot->Question[0]->ChosenAnswer;

For some reason, the script isn't returning anything.

Was it helpful?

Solution

Firstly, you need to create instance of SimpleXML to use it.

$bot = file_get_contents("http://answers.yahooapis.com/AnswersService/V1/questionSearch?appid=API_KEY&query=".$q1."");
$bot = simplexml_load_string($bot);
echo $bot->Question[0]->ChosenAnswer;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top