1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

phpでhttp,htttps通信用関数

Last updated at Posted at 2014-12-22
function get_url_data($url){
    $ch = curl_init($url);
    session_start();
//    curl_setopt($ch, CURLOPT_URL,$url);
    //証明書を無視
    curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
    //タイムアウトの設定
    curl_setopt( $ch, CURLOPT_TIMEOUT, 50 );
    $getCode = curl_exec($ch);
    curl_close($ch);
    return $getCode;
}

// POST用のメソッド
function get_url_data_post($url,$arr){
    $postdata = http_build_query($arr);

    $ch = curl_init();
    session_start();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_TIMEOUT, 50);

    $getCode = curl_exec($ch);
    curl_close($ch);
    return $getCode;
}
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?