Back to tech

phpでfile_get_contentsを行う際のプロキシ設定

1 min read
Table of Contents
プロキシ経由でfile_get_contents - Road To Nowhere
kazumaryu.hatenablog.com
image

結論から言うと、プロキシ経由でアクセスするためにプロキシ設定をしなければなりませんでした。

以下ソース

<?php
$proxy = array(
      "http" => array(
         "proxy" => "tcp://サーバー名:ポート番号",
         'request_fulluri' => true,
      ),
);
$proxy_context = stream_context_create($proxy);
echo file_get_contents("http://www.google.co.jp/?gws_rd=ssl",false,$proxy_context);
?>

参考