Yahooのコンテンツ分析を使おうとしていますが、ここからはとても使いやすいようです
しかし、コードを実行するたびに、次の出力がそのまま表示されます。
Italian sculptors the Virgin Mary painters http://en.wikipedia.com/wiki/Painting http://en.wikipedia.com/wiki/Adobe_Photoshop http://en.wikipedia.com/wiki/Still_life http://en.wikipedia.com/wiki/Avant-garde http://en.wikipedia.com/wiki/In_the_Sky http://en.wikipedia.com/wiki/Potato 1
私が欲しいのは、このリンクをクリックしたときのように、XMLタグで構造化されたXMLドキュメントを表示することです。
また、出力として表示されているもののソースコード(ブラウザから..右クリック>ソースを表示)は次のとおりです。
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="1" yahoo:created="2012-11-24T05:54:55Z" yahoo:lang="en-US"><results><entities xmlns="urn:yahoo:cap">
<entity score="0.784327">
<text end="16" endchar="16" start="0" startchar="0">Italian sculptors</text>
</entity>
<entity score="0.78097">
<text end="72" endchar="72" start="58" startchar="58">the Virgin Mary</text>
</entity>
<entity score="0.509566">
<text end="29" endchar="29" start="22" startchar="22">painters</text>
<wiki_url>http://en.wikipedia.com/wiki/Painting</wiki_url>
<related_entities>
<wikipedia>
<wiki_url>http://en.wikipedia.com/wiki/Adobe_Photoshop</wiki_url>
<wiki_url>http://en.wikipedia.com/wiki/Still_life</wiki_url>
<wiki_url>http://en.wikipedia.com/wiki/Avant-garde</wiki_url>
<wiki_url>http://en.wikipedia.com/wiki/In_the_Sky</wiki_url>
<wiki_url>http://en.wikipedia.com/wiki/Potato</wiki_url>
</wikipedia>
</related_entities>
</entity>
</entities></results></query><!-- total: 191 -->
<!-- engine6.yql.ac4.yahoo.com -->
1
以下は私のコードです:
<?php
$c = curl_init();
curl_setopt($c, CURLOPT_URL, 'http://query.yahooapis.com/v1/public/yql');
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, "q=select * from contentanalysis.analyze where text='Italian sculptors and painters of the renaissance favored the Virgin Mary for inspiration';");
curl_setopt($c,CURLOPT_HEADER,0);
$op=curl_exec ($c);
curl_close ($c);
echo $op;
?>