Exemplo n.º 1
0
function get_facebook_infos($id)
{
    $url = 'https://graph.facebook.com/';
    $data = array('id' => $id);
    $url .= '?' . http_build_query($data);
    return get_content($url);
}
// Use the functions above to get infos
$error = '';
$user = false;
if (!empty($_POST) && !empty($_POST['id'])) {
    $id = $_POST['id'];
    $key = 'facebook_' . $id;
    if (!($infos = $cache->get($key))) {
        echo 'Not from cache';
        $infos = get_facebook_infos($id);
        $cache->set($key, $infos);
    } else {
        echo 'From cache';
    }
    if (!empty($infos->error)) {
        $error = $infos->error->message;
    } else {
        $user = $infos;
    }
}
?>
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
Exemplo n.º 2
0
 * GET FACEBOOK INFOS
 * Use public API https://graph.facebook.com/
 * Use get_content function above
 */
function get_facebook_infos($id)
{
    $url = 'https://graph.facebook.com/';
    $data = array('id' => $id);
    $url .= '?' . http_build_query($data);
    return get_content($url);
}
// Use the functions above to get infos
$error = '';
$user = false;
if (!empty($_POST) && !empty($_POST['id'])) {
    $infos = get_facebook_infos($_POST['id']);
    if (!empty($infos->error)) {
        $error = $infos->error->message;
    } else {
        $user = $infos;
    }
}
?>
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Facebook infos</title>
</head>
<body>
	<form action="#" method="POST">