shutterstock接口对接API 获取图片

创建应用程序,获取两个密匙。
https://www.shutterstock.com/account/developers/apps

安装:
composer require shutterstock/api

    public function tests(){
    
    
        require_once ROOT_PATH . '/vendor/autoload.php';

        $client = new \Shutterstock\Api\Client('rAM5LPelwV9XuxS3GDKK0py8L3O6m55W', 'VAvU5Zm6AK3GAGdR');
        // perform an image search for puppies
        $imageResponse =$client->get('images/search', array('query' => 'puppies'));

// retrieve details for a handful of image ids
//        $imageResponse = $client->get('images', array('id' => array(1, 2, 3)));

// create a lightbox
//        $client->post('images/collections', array('name' => 'Lightbox Name Here'));
//        $imageResponse = $client->get('images', array('id' => array(1, 2, 3)));



        if ($imageResponse->getStatusCode() != 200) {
    
    
            // error handler
        } 
        $images = $imageResponse->getBody()->jsonSerialize()['data'];
        dd($images);
// etc
    }

猜你喜欢

转载自blog.csdn.net/weixin_42433970/article/details/111198746