2013-10-21 226 views
0

我正在嘗試使用AlchemyAPI的php sdk。我正在運行Github page上給出的相同示例。 但是當我嘗試運行的例子中,我得到這個錯誤MESSAGE-alchemyAPI for php not working

Warning: fclose() expects parameter 1 to be resource, boolean given in C:\wamp\www\twitter-analysis\alchemyapi.php on line 261 

可能是什麼原因?在alchemyapi.php,這是在警告occuring-

private function analyze($url, $params) { 
     //Insert the base URL 
     $url = $this->_BASE_URL . $url; 

     //Add the API Key and set the output mode to JSON 
     $url = $url . '?apikey=' . $this->_api_key . '&outputMode=json'; 

     //Add the remaining parameters 
     foreach($params as $key => $value) { 
      $url = $url . '&' . $key . '=' . $value; 
     } 

     //Create the HTTP header 
     $header = array('http' => array('method' => 'POST', 'Content-type'=> 'application/x-www-form-urlencoded')); 

     //Fire off the HTTP Request 
     try { 
      $fp = @fopen($url, 'rb',false, stream_context_create($header)); 
      $response = @stream_get_contents($fp); 
      fclose($fp); 
      return json_decode($response, true); 
     } catch (Exception $e) { 
      return array('status'=>'ERROR', 'statusInfo'=>'Network error'); 
     } 
    } 
} 

回答

0

嘗試測試現場服務器上。 我的經驗,它在本地服務器在現場服務器工作的錯誤。