Php 谷歌图片搜索

Php 谷歌图片搜索,php,laravel,Php,Laravel,在我的应用程序中,用户创建文章并向其中添加图像,如果用户不添加图像,该应用程序必须在谷歌图像中搜索。我在谷歌上搜索了很长时间,但仍然找不到实现这一点需要哪些工具 编辑 我尝试了Mimos方法,但现在出现了一些问题,现在我得到: NotReadableException in AbstractDecoder.php line 302: Image source not readable 当我试图从url保存图像时 ArticlesController存储方法: public function

在我的应用程序中,用户创建文章并向其中添加图像,如果用户不添加图像,该应用程序必须在谷歌图像中搜索。我在谷歌上搜索了很长时间,但仍然找不到实现这一点需要哪些工具

编辑 我尝试了Mimos方法,但现在出现了一些问题,现在我得到:

NotReadableException in AbstractDecoder.php line 302:
Image source not readable
当我试图从url保存图像时

ArticlesController存储方法:

 public function store(ArticleRequest $request)
    {
        if ($request->hasFile('file')) {

            $file = Input::file('file');
            $imgTitle = $request->title;
            $imagePath = 'uploads/' . $imgTitle . '.jpg';
            $request->image_path = $imagePath;

            Article::create(array('title' => $request->title,
                'body' => $request->body,
                'image_path' => $imagePath));

            Image::make($file)->resize(300, 200)->save($imagePath);
        } else {
//            $file = Input::file('file');
            $imgTitle = $request->title;

            $query = $imgTitle;

            $ch = curl_init();

            curl_setopt($ch, CURLOPT_URL, "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=" . urlencode($query));

            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

            $output = json_decode(curl_exec($ch));

//            $file = file_get_contents($output);
            curl_close($ch);

            $imagePath = 'uploads/' . $imgTitle . '.jpg';

            $request->image_path = $imagePath;
            Article::create(array('title' => $request->title,
                'body' => $request->body,
                'image_path' => $imagePath));

            Image::make($output)->resize(300, 200)->save($imagePath);

        }

    }

不清楚、脱离主题(要求外部工具)且内容太广泛。请在发帖前复习。谢谢,我会试试的。这只是练习。
<?php
$query = 'Foobar';
$ch = curl_init(); 
// set url 
curl_setopt($ch, CURLOPT_URL, "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=".urlencode($query));

//return the transfer as a string 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

// $output contains the output string as json
$output = json_deocde(curl_exec($ch));

// close curl resource to free up system resources 
curl_close($ch);