Skip to content

Instantly share code, notes, and snippets.

@ksomemo
Created November 7, 2014 04:04
Show Gist options
  • Save ksomemo/e32e7a2d60f6f7f2f3ba to your computer and use it in GitHub Desktop.
Save ksomemo/e32e7a2d60f6f7f2f3ba to your computer and use it in GitHub Desktop.
Webビーコン Sample
(function() {
var action_target = document.createElement('img');
action_target.width = 1;
action_target.height = 1;
action_target.alt = "";
action_target.src = '/api/action';
document.body.appendChild(action_target);
console.log("action");
})();
<?php
// using laravel
class ActionController extends BaseController
{
public function getIndex()
{
$expires = gmdate('r', time('1970-01-01 00:00:00'));
$headers = [
'Cache-Control' => 'private, no-cache, must-revalidate',
'Expires' => $expires,
'Pragma' => 'no-cache',
'Content-Length' => 1,
'Content-Type' => 'image/gif'
];
$onePixelGif = base64_decode("R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw%3D%3D");
return Response::make($onePixelGif, 200, $headers);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment