Skip to content

Instantly share code, notes, and snippets.

@luizmarcus
Created July 10, 2022 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luizmarcus/35cbd54b60bbd1bfd44ec6196848df67 to your computer and use it in GitHub Desktop.
Save luizmarcus/35cbd54b60bbd1bfd44ec6196848df67 to your computer and use it in GitHub Desktop.
<?php
define('URL_API','https://api.unsplash.com/search/photos/?client_id=[CLIENT_ID]&query=computer&orientation=landscape&per_page=8');
$response = file_get_contents(URL_API);
$json = json_decode($response, true);
$images = array();
foreach($json['results'] as $image){
array_push($images, $image['urls']['regular']);
}
echo json_encode($images);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment