简体   繁体   中英

curl_init conflict with wordpress on twitter oAuth

I am using the Abraham Williams twitter library on my Wordpress development. I am at the stage of validating everything and the oAuth.php has produced a potential error on the theme check plugin required for Themeforest.

WARNING: curl_init was found in the file includes/resources/twitter/twitteroauth.php possible file operations.

and

WARNING: curl_exec was found in the file includes/resources/twitter/twitteroauth.php possible file operations.

This is in the following function

function http($url, $method, $postfields = NULL) {
    $this->http_info = array();
    $ci = curl_init();
    /* Curl settings */
    curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
    curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
    curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
    curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
    curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
    curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
    curl_setopt($ci, CURLOPT_HEADER, FALSE);

    switch ($method) {
      case 'POST':
        curl_setopt($ci, CURLOPT_POST, TRUE);
        if (!empty($postfields)) {
          curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
        }
        break;
      case 'DELETE':
        curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
        if (!empty($postfields)) {
          $url = "{$url}?{$postfields}";
        }
    }

    curl_setopt($ci, CURLOPT_URL, $url);
    $response = curl_exec($ci);
    $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
    $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
    $this->url = $url;
    curl_close ($ci);
    return $response;
  }

Does anyone know a fix for this?

NOTE

From further reading it is recommended to use

wp_remote_request()

Any experience with this?

This is not an error, it's a warning.

It also doesn't look like it coming from PHP since it does not contain the line and PHP warnings are spelled Warning not WARNING .

This looks like a security feature of Wordpress to tell you curl executions in plugins and scripts.

You should open a case here: http://wordpress.org/support/plugin/theme-check

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM