108
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

Organization

PHPのcurlでPOST

curl_post.php
$POST_DATA = array(
    'foo' => 'bar'
);
$curl=curl_init("URL");
curl_setopt($curl,CURLOPT_POST, TRUE);
// ↓はmultipartリクエストを許可していないサーバの場合はダメっぽいです
// @DrunkenDad_KOBAさん、Thanks
//curl_setopt($curl,CURLOPT_POSTFIELDS, $POST_DATA);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($POST_DATA));
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER, FALSE);  // オレオレ証明書対策
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST, FALSE);  // 
curl_setopt($curl,CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl,CURLOPT_COOKIEJAR,      'cookie');
curl_setopt($curl,CURLOPT_COOKIEFILE,     'tmp');
curl_setopt($curl,CURLOPT_FOLLOWLOCATION, TRUE); // Locationヘッダを追跡
//curl_setopt($curl,CURLOPT_REFERER,        "REFERER");
//curl_setopt($curl,CURLOPT_USERAGENT,      "USER_AGENT"); 

$output= curl_exec($curl);
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
108
Help us understand the problem. What are the problem?