「Php/curl/基本」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→例) |
|||
行1: | 行1: | ||
==例== | ==例== | ||
− | |||
$post["hoge"] = "piyo"; | $post["hoge"] = "piyo"; | ||
$chost = curl_init(); | $chost = curl_init(); | ||
curl_setopt($chost, CURLOPT_URL, "ttp://example.com/hogehoge.php"); | curl_setopt($chost, CURLOPT_URL, "ttp://example.com/hogehoge.php"); | ||
− | curl_setopt($chost, CURLOPT_POST, true); | + | curl_setopt($chost, CURLOPT_POST, true); // methodをpostに |
curl_setopt($chost, CURLOPT_POSTFIELDS, $post); | curl_setopt($chost, CURLOPT_POSTFIELDS, $post); | ||
curl_setopt($chost, CURLOPT_RETURNTRANSFER, true); | curl_setopt($chost, CURLOPT_RETURNTRANSFER, true); | ||
$result = curl_exec($chost); | $result = curl_exec($chost); | ||
curl_close($chost); | curl_close($chost); | ||
− | echo $result; | + | echo $result; |
2017年11月30日 (木) 16:48時点における最新版
例
$post["hoge"] = "piyo"; $chost = curl_init(); curl_setopt($chost, CURLOPT_URL, "ttp://example.com/hogehoge.php"); curl_setopt($chost, CURLOPT_POST, true); // methodをpostに curl_setopt($chost, CURLOPT_POSTFIELDS, $post); curl_setopt($chost, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($chost); curl_close($chost); echo $result;