protected function generate($year, $month)
 {
     HttpClient::init(['applicationId' => env('IMG_ID'), 'secret' => env('IMG_SECRET')]);
     $date = Carbon::now();
     $date->year = $year;
     $date->month = $month;
     $date->startOfMonth();
     $end = $date->copy()->endOfMonth();
     while ($date->lte($end)) {
         $random = uPhoto::random();
         $link = $random->links['html'];
         $image = $random->urls['thumb'];
         Photo::create(['date' => $date->toDateString(), 'link' => $link, 'image' => $image]);
         $date->addDays(1);
     }
     return redirect('view/' . $year . '/' . $month);
 }
Example #2
0
 public function __construct($id)
 {
     HttpClient::init(['applicationId' => \get_field('ai_unsplash_api_key', 'option'), 'secret' => \get_field('ai_unsplash_api_secret', 'option')]);
     $this->id = $id;
 }
 public function testInitConnectionWithAccessTokenObject()
 {
     Unsplash\HttpClient::init(['applicationId' => 'mock_application_id'], $this->accessToken);
     $this->assertEquals('Bearer ' . getenv('ACCESS_TOKEN'), Unsplash\HttpClient::$connection->getAuthorizationToken());
 }
 /**
  * Unsplash constructor (start HttpClient)
  */
 public function __construct()
 {
     HttpClient::init(['applicationId' => $this->applicationId]);
 }
 public function setUp()
 {
     parent::setUp();
     Unsplash\HttpClient::init(['clientId' => 'mock_client_id', 'clientSecret' => 'mock_secret', 'redirectUri' => 'none'], ['access_token' => getenv('ACCESS_TOKEN')]);
 }