0
我使用PHP版本5.5.9如何解決不推薦使用:在tmhOAuth.php curl_setopt()(Twitter)上
嘗試發佈圖片到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我有這樣的警告「開捕致命錯誤:類CURLFile的對象無法轉換爲字符串。」 – 2014-10-10 09:47:28
@ a.fauzi以顯示你的代碼'curl_file_create' – fiction 2014-10-10 09:51:23
$ image =「C:/xampp/htdocs/project_folder/photos/small_1412933689.jpg」; $ img = curl_file_create($ image); $ code = $ tmhOAuth-> user_request(array( 'method'=>'POST', 'url'=>「https://api.twitter.com/1.1/statuses/update_with_media.json」, ' params'=> array( 'media []'=>「@」。$ img。「; type = image/jpeg; filename = {$ imagename}」, 'status'=> $ _SESSION ['content_text'] ), 'multipart'=> true )); – 2014-10-10 10:18:16