2012-04-14 5 views
0

私はdrupalコードから関数を移植するための助けが必要です。drupal_http_requestから移植されたfile_get_contents

、私はdrupal_http_requestは基本的にのfile_get_contentsであることが判明しているが、私はそれを変更するとき、私は取得エラーであるように見える

オリジナルのDrupalのコードは次のとおりです。

$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