Search code examples
phpseofile-get-contents

can i simulate a user's visit with file_get_contents()


Im thinking in a cron which executes daily one php script. This script will make a file_get_contents() to one url I assign. Can i do this for simulate a user's visit? Does it work like a visit?

$page = file_get_contents('http://www.example.com/');
echo $page;

Solution

  • You can "simulate" this kind of action, but it's better to be done with curl. Also to do this I would recommend going through this stackoverflow post, it explains all the variables which are needed to be supplied by doing a server side request, rather than opening the page through a browser and loading the analytics js.