24
23

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でcurlを使ってHTTPSにアクセスしてエラー出たときの回避策

Posted at

OAuth2.0認証を利用して、Instagramでアプリ認証を行なう過程で
curl_exec()実行したら、bool(false)が返ってきた。
これはHTTPSにアクセスするときに起きる。
カールは、サーバのHTTPS証明書を信頼するように設定されていないので、"下記一行を追加"のコードを追加して対策。

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
//下記一行を追加
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER, false);

$res = curl_exec($curl);
curl_close($curl);
var_dump($res);
exit;
24
23
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
24
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?