Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何从imgurapi返回的对象获取链接_Php_Laravel_Imgur - Fatal编程技术网

Php 如何从imgurapi返回的对象获取链接

Php 如何从imgurapi返回的对象获取链接,php,laravel,imgur,Php,Laravel,Imgur,我正在使用: 1.拉维尔5号 2. 我的控制器: public function store() { $input = Request::all(); $upload = new Upload($input); $upload->save(); $upload_id = $upload->id; $path = $this->resizeAndSaveTempImage($upl

我正在使用: 1.拉维尔5号 2.

我的控制器:

public function store()
    {
        $input = Request::all();

        $upload = new Upload($input);

        $upload->save();

        $upload_id = $upload->id;

        $path =  $this->resizeAndSaveTempImage($upload->raw_image_url);

        $done = $this->uploadToImgur($path);

        dd($done);



    }

public function resizeAndSaveTempImage($image_url)
    {


        $img = Image::make($image_url)->insert('http://i.imgur.com/Ned0D1ub.jpg', 'top', 130, 330);

        $tmp_name = 'final-output-' . microtime(true) . '.jpg';

        $path = 'tmp/' . $tmp_name;

        $img->save($path);

        return $path;



    }

    public function uploadToImgur($image_path)
    {
        $imageData = array(
            'image' => $image_path,
            'type'  => 'file',
            'name' => 'Lipsum',
            'title' => 'Lorem Ipsum',
            'description' => 'Lorem Ipsum Dolor Sit Amet'
        );

        $basic = Imgur::api('image')->upload($imageData);

        return $basic;
    }
模具和卸载的结果:

Basic {#236 ▼
  -data: array:20 [▼
    "id" => "KWIhRsS"
    "title" => "Lorem Ipsum"
    "description" => "Lorem Ipsum Dolor Sit Amet"
    "datetime" => 1431732751
    "type" => "image/jpeg"
    "animated" => false
    "width" => 640
    "height" => 640
    "size" => 95601
    "views" => 0
    "bandwidth" => 0
    "vote" => null
    "favorite" => false
    "nsfw" => null
    "section" => null
    "account_url" => null
    "account_id" => 0
    "deletehash" => "z8M21wNHdsFOBhJ"
    "name" => "Lipsum"
    "link" => "http://i.imgur.com/KWIhRsS.jpg"
  ]
  -success: true
  -status: 200
}
但是如果我尝试访问链接

dd($done->data['link']);
它给了我这个错误:

Cannot access private property Imgur\Api\Model\Basic::$data

如何从响应对象访问链接?

在研究此处的代码后:

Im使用的包对其进行了扩展,返回对象的$data属性存在一个getter

$done->getData()