0
我使用由imgur API返回的对象链接: 1. Laravel 5 2. https://github.com/MarkRedeman/Imgur-Laravel如何获得
我的控制器:
: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
如何访问从响应对象的链接?