Facebook Realtime Updates API を使用しようとしています...次のコードがあります:
<?php
define('VERIFY_TOKEN', '*');
$method = $_SERVER['REQUEST_METHOD'];
if ($method == 'GET' && $_GET['hub_mode'] == 'subscribe' && $_GET['hub_verify_token'] == VERIFY_TOKEN) {
echo $_GET['hub_challenge'];
} else if ($method == 'POST') {
$hostname = "*";
$username = "*";
$dbname = "*";
$password = "*";
mysql_connect($hostname, $username, $password) OR DIE('Unable to connect to database! Please try again later.');
mysql_select_db($dbname) or die(mysql_error());
$post_body = file_get_contents("php://input");
$object = json_decode($post_body, true);
foreach ($object->entry as $update) {
// For each entry in notification, insert a row of information into the table "FaceBook"
$changed_fields = $update->changed_fields[0];
$result = mysql_query("INSERT INTO FaceBook (uid, id, time, changed_fields) VALUES('$update->uid', '$update->id', '$update->time', '$changed_fields')")
or die(mysql_error());
}
mysql_close();
}
?>
今、更新が発生すると、facebook は POST 要求を送信していますが、foreach ループには入っていません... $object が空かどうかを確認しようとしましたが、2 つの要素が返されます (count を使用)。
何か案は?