Ad

Can I Simulate A User's Visit With File_get_contents()

- 1 answer

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;
Ad

Answer

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.

Ad
source: stackoverflow.com
Ad