Skip to content

Instantly share code, notes, and snippets.

@riaf
Created June 21, 2012 04:26
Show Gist options
  • Save riaf/2963830 to your computer and use it in GitHub Desktop.
Save riaf/2963830 to your computer and use it in GitHub Desktop.
コマンドラインで OGP をデバッグする ref: http://qiita.com/items/d132f8a5f0961502bad5
#!/usr/bin/env php
<?php
if (!isset($argv[1])) {
echo "Usage: php ogp.php [URL]", PHP_EOL;
exit;
}
$data = http_build_query(array(
'id' => $argv[1],
'scrape' => 'true',
));
$context = array(
'http' => array(
'method' => 'POST',
'header' => implode("\r\n", array(
'Content-Type: application/x-www-form-urlencoded',
'Content-Length: '.strlen($data),
)),
'content' => $data,
),
);
var_dump(json_decode(file_get_contents(
'https://graph.facebook.com',
false,
stream_context_create($context)
), true));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment