1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <?php $text = 'This domain name expired on 12/6/2014 and is pending renewal or deletion.' ; $query = "select * from contentanalysis.analyze where text = '" . $text . "'" ; $yql_query_url = $url . "?q=" . urlencode( $query ); $yql_query_url .= "&format=json" ; $yql_query_url .= "&enable_categorizer=true" ; $yql_query_url .= "&diagnostics=false" ; $yql_query_url .= "&related_entities=true" ; $yql_query_url .= "&show_metadata=true" ; $ch = curl_init( $yql_query_url ); curl_setopt( $ch , CURLOPT_RETURNTRANSFER,true); $result = curl_exec( $ch ); curl_close( $ch ); $result = json_decode( $result ); var_dump( $result ); if (! is_null ( $result ->query->results)) { foreach ( $result ->query->results->entities as $word ) { if ( is_array ( $word )) { foreach ( $word as $subword ) { echo $subword ->text->content. "\n" ; } } else { echo $word ->text->content. "\n" ; } } } ?> |
文档:https://developer.yahoo.com/search/content/V2/contentAnalysis.html
标签:none