CURL setopt无法正常工作

时间:2012-05-09 22:19:09

标签: php curl ssh

  

可能重复:
  mysql_fetch_array() expects parameter 1 to be resource, boolean given in select

我正在开发一个导入MLS列表数据的PHP脚本。当我通过CLI执行脚本时,我收到以下错误:

PHP警告:curl_setopt()要求参数1为资源,字符串在第283行的/var/www/clients/client4/web4/web/wp-content/plugins/import-rets/RETS_class.php中给出 PHP警告:curl_exec()期望参数1是资源,字符串在284行/var/www/clients/client4/web4/web/wp-content/plugins/import-rets/RETS_class.php中给出 PHP警告:curl_error()期望参数1是资源,字符串在第287行的/var/www/clients/client4/web4/web/wp-content/plugins/import-rets/RETS_class.php中给出 PHP警告:curl_getinfo()期望参数1是资源,字符串在第295行的/var/www/clients/client4/web4/web/wp-content/plugins/import-rets/RETS_class.php中给出 PHP警告:curl_close()期望参数1是资源,字符串在第191行的/var/www/clients/client4/web4/web/wp-content/plugins/import-rets/RETS_class.php中给出 PHP警告:curl_setopt()期望参数2为long,第283行的/var/www/clients/client4/web4/web/wp-content/plugins/import-rets/RETS_class.php中给出的数组 PHP警告:curl_setopt()期望参数2为long,第283行/var/www/clients/client4/web4/web/wp-content/plugins/import-rets/RETS_class.php中给出的数组

这是我的代码:

 if (!$this->user_agent_auth )  {
 $options[CURLOPT_HTTPAUTH] = CURLAUTH_DIGEST|CURLAUTH_BASIC;
 $options[CURLOPT_USERPWD]  = $this->account.":".$this->password;
 } elseif ($this->exec_count <> 1 ) {
 $options[CURLOPT_HTTPAUTH] = CURLAUTH_DIGEST;
 $options[CURLOPT_USERPWD]  = $this->account.":".$this->password;
 }
 curl_setopt($this->ch, $options, $value);
 $response = curl_exec($this->ch);


 $error = curl_error($this->ch);
 if ( $error != '' ) {
 $this->response['curl_error'] = $error;
 $this->response['request_header'] ='';
 $this->response['received_header']='';
 $this->response['received_body']  ='';
 $this->response['http_code']      ='';
 } else {
 $this->response = curl_getinfo( $this->ch );
 $this->response['curl_error'] = '';
 $this->response['received_header'] = substr( $response, 0, $this->response['header_size'] );
 $this->response['received_body'] = substr( $response, $this->response['header_size'] );
 }
 $this->response['data'] = $data;

任何支持都将不胜感激。

1 个答案:

答案 0 :(得分:7)

您是否将$this->ch设置为curl实例?

$this->ch = curl_init();

您可能打算使用curl_setopt_array而不是curl_setopt。