簡體   English   中英

如何修復不推薦使用:tmhOAuth.php中的curl_setopt()(twitter)

[英]how to fix Deprecated: curl_setopt() in tmhOAuth.php (twitter)

我使用PHP版本5.5.9

嘗試將圖像發布到Twitter,但是我有這個警告:

Deprecated: curl_setopt(): The usage of the @filename API for file uploading is deprecated. Please use the CURLFile class instead in C:\xampp\htdocs\project_folder\libs\tmhOAuth\tmhOAuth.php on line 771

當我檢查文件tmhOAuth.php上的腳本時,如下所示:

758    $c = curl_init();
759    switch ($this->request_settings['method']) {
760      case 'GET':
761        if (isset($this->request_settings['querystring']))
762          $this->request_settings['url'] = $this->request_settings['url'] . '?' . $this->request_settings['querystring'];
763        break;
764      case 'POST':
765        curl_setopt($c, CURLOPT_POST, true);
766        if (isset($this->request_settings['postfields']))
767          $postfields = $this->request_settings['postfields'];
768        else
769          $postfields = array();
770
771        curl_setopt($c, CURLOPT_POSTFIELDS, $postfields);
772        break;
773      default:
774        if (isset($this->request_settings['postfields']))
775          curl_setopt($c, CURLOPT_CUSTOMREQUEST, $this->request_settings['postfields']);
776    }

我該如何解決..?

您需要使用函數curl_file_create();處理所有文件curl_file_create(); ,fe

<?php
    $path = '/path/to/file';
    $file = curl_file_create($path);
    $c = curl_init();
    curl_setopt($c, CURLOPT_POSTFIELDS, array('file' => $file));

鏈接到人[curl_file_create]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM