I made a PHP library that implements the "Way 1" method, it will give you great control over the request, it's built for Laravel but you could just copy the logic and use it in any PHP application. https://packagist.org/packages/oliverlundquist/laravel-http-background