سؤال

$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.

هل كانت مفيدة؟

المحلول

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;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top