3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

コマンドラインで OGP をデバッグする

Last updated at Posted at 2012-06-21

Facebook のデバッガー ( http://developers.facebook.com/tools/debug ) も便利ですが、Graph API 経由でも ogp を確認出来ます。

#!/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));

うん、雑なコード。

3
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?