unsplash-php icon indicating copy to clipboard operation
unsplash-php copied to clipboard

Script works in the browser, but fails on CRONJOB, FETCH, or RUN SCRIPT

Open aerialglasgow opened this issue 2 years ago • 0 comments

Thanks for the PHP documentation. I have set up a script which successfully authenticates with API and retrieves public photos responses in JSON by search below:

Unsplash\HttpClient::init([
	'applicationId'	=> 'YOUR ACCESS KEY',
	'secret'	=> 'YOUR APPLICATION SECRET',
	'callbackUrl'	=> 'https://your-application.com/oauth/callback',
	'utmSource' => 'NAME OF YOUR APPLICATION'
]);

Then using $result = Unsplash\Search::photos($search, $page, $per_page);

When I run the script URL in the browser it works and returns the JSON photos array.

When I try to run the script from the server by CRONJOB, or FETCH, or RUN SCRIPT methods it fails on the first attempt here

\Unsplash\HttpClient::init([ .... });

I've made many changes to try to fix this but without success. Do you know why the script / authentication might be failing?

aerialglasgow avatar Jul 07 '23 14:07 aerialglasgow