2012-04-14 4 views
0

Drupal 코드에서 함수를 이식하는 데 도움이 필요합니다.drupal_http_request에서 이식 된 file_get_contents

, 내가 drupal_http_request 기본적으로 file_get_contents 것을 ​​발견했다,하지만 난 그것을 변경할 때, 나는 점점 오류 것 같다

원래 드루팔 코드는 다음과 같다 :

$response = drupal_http_request($url, array('Content-Type' => 'text/xml'), 'POST', $post_data); 

는 기본적으로 모든 메신저 일 그렇게는
$response = file_get_contents($url, array('Content-Type' => 'text/xml'), 'POST', $post_data); 

과 같이 그래도 난이 프로그램을 실행할 때 ... 나는 다음과 같은 오류 메시지가 보이는 대체

file_get_contents() expects parameter 2 to be boolean 

누구든지 나를 이식 할 수 있는지 궁금합니다.

감사

답변

1

file_get_contents 그것을 위해 ... 덕분에 의미가 상세 예

$opts = array (
     'http' => array (
       'method' => "POST", 
       'header' => 'Content-Type: text/xml\r\n', 
       'content' => $post_data 
     ) 
); 
$context = stream_context_create ($opts); 
$data = file_get_contents ($url, false, $context); 
+0

아,에 대한 http://php.net/manual/en/function.file-get-contents.php를 참조 두 번째 인수로 배열을 고려하지 않습니다 :) – BigJobbies