php初心者ですphpを使ってpostリクエストを実装したいのですが
<?php $url = "https://hoge.com"; $data = array( 'id' => 100, 'name' => "Mike" ); $context = array( 'http' => array( 'method' => 'POST', 'header' => implode("\r\n", array('Content-Type: application/x-www-form-urlencoded',)), 'content' => http_build_query($data) ) ); //おそらく今の実装でhttps://hoge.com?id=100&name=Mikeになっているはず. $html = file_get_contents($url, false, stream_context_create($context)); echo $html;
上記のコードの中にform-dataとして
api_key = 1234567890 user_key = abcdefg
みたいなデータを付与して送りたいのですが書き方が全くわかりません。
解決策をご存知でしたらよろしくお願いします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。