API からスクリーンショットを取得しようとしましたが、画像をデコードして保存すると、壊れた画像が表示されます。以下は私が使用しているコードです。テストしたい場合は、Google 応答を含むサンプル ファイルへの tinyurl を作成しました。
$name = 'test';
$result = file_get_contents('http://tinyurl.com/q4smyod');
$result = json_decode($result, true);
$decoded=base64_decode($result['screenshot']['data']);
file_put_contents('img/'.$name.'.jpg',$decoded);