문제

$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