2014-10-10 3 views
0

을 (트위터) 내가 트위터에 이미지를 게시하는 PHP 버전 5.5.9: tmhOAuth.php에 curl_setopt()를

시도를 사용하지만, 난이 경고가 :

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 } 

어떻게 수정합니까?

답변

0

모든 파일을 기능 curl_file_create();, f.e.로 처리해야합니다. 내가 curl_file_create를 사용할 때

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

link to man [curl_file_create]

+0

내가이 경고를 "잡아낼 치명적인 오류가 : 클래스 CURLFile의 객체가 문자열로 변환 할 수 없습니다 ..." –

+0

을 a.fauzi과 함께 코드를 보여 @' – fiction

+0

을 curl_file_create' $ 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", ' $ _SESSION [ 'content_text'] 매개 변수 => $ _SESSION '=>'매개 변수 '> => 배열 ( 'media [] '=> "@". $ img. ";), 'multipart'=> true )); –