All pastes #186162 Raw Edit

Anonymous

public text v1 · immutable
#186162 ·published 2006-09-29 17:04 UTC
rendered paste body
    function suggestKeywords($content){
        $bad_keywords = $GLOBALS['DNL_bad_keywords'];
        $url = "http://api.search.yahoo.com/ContentAnalysisService/V1/termExtraction";
        $ch = curl_init();
        $content = utf8_encode($content);
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, "appid=dotsandloops&query=null&context=$content");
        $result = curl_exec ($ch);
        curl_close ($ch);
        preg_match_all('|<result>(.*?)</result>|i', $result, $keywords);
        $good_keywords = array();
        foreach($keywords[1] as $keyword) {
            $keyword = trim($keyword);
            $found = array_search($keyword, $bad_keywords);
            ob_start(); var_dump($found); $out = ob_get_contents(); ob_end_clean();
            error_log("found = $out");

            if($found === NULL || $found === false)
                $good_keywords[] = $keyword;
        }
        return($good_keywords);
    }