3

こんにちは、私は以下を機能させようとしています。相手側で確認できるため、HTTP 要求を作成していますが、2 つの値とパラメーターを渡していません。

誰でも助けることができますか?

<?php

$url = "http://example.com/ws.php?uid=0000&pin=0000";
$fields = array(
    'target1' => $_GET['target1'],
    'target2' => $_GET['target2']);

$data = http_build_query($fields);

$context = stream_context_create(array(
'http' =>  array(
    'method'  => 'POST',
    'header'  => 'Content-type: application/x-www-form-urlencoded',
    'content' => $data,
)
));

$result = file_get_contents($url, false, $context);

echo $data."<br />";
echo($result); 

?>
4

2 に答える 2

1

私が見た例に基づいて\r\n、ヘッダー値の最後に が必要です。

'header'  => "Content-type: application/x-www-form-urlencoded\r\n" 

それとは別に、あなたも提供する必要があります

"Content-Length: " . strlen($data) . "\r\n",
于 2013-07-04T10:16:24.507 に答える