PHP[紀錄]file_get_contents讀取錯誤

25 3月, 2017

PHP[紀錄]file_get_contents讀取錯誤




目前最近有個需求,需要對一個IG的Hashtag頁面內容進行解析
所以使用PHP來進行開發

file_get_contents

目前是用來讀取檔案的,將一個檔案內的內容資訊讀寫成一個字串
在這用它來將IG的頁面內容資訊倒出

<?php 
 $tag = "happy";
 $insta_source = file_get_contents('https://www.instagram.com/explore/tags/'.$tag.'/');
?>

但是在執行上,卻出現了以下的錯誤訊息問題
?


Warning: file_get_contents(https://www.instagram.com/explore/tags/happy/) [function.file-get-contents]: failed to open stream: Invalid argument in C:\AppServ\www\igContent.php on line 3


似乎是PHP再調用file_get_contents時,解析https的內容的時候產生了錯誤。
解決方式是將php的openssl模組給打開

去php.ingo將以下的「;」拿掉

;extension=php_openssl.dll

再將伺服器進行重起就可以順利運行

張貼留言