Grafik API kullanarak PHP ile Facebook Stream Yayınla

0 Cevap php

Ben yeni grafik API ve PHP kullanarak bir kullanıcının duvarına bir mesaj göndermek için çalışıyorum. Bağlantı iyi çalışıyor görünüyor, ama hiçbir sonrası görünür. Ben gönderme kodunu doğru kurmak için nasıl emin değilim. Bana yardım edin. StackOverflow kod bloğu içinde tüm kapatmak istemedim nedense, kırık görünümlü kodu için üzgünüm.

Aşağıda benim tam kodudur. Ben bir genişletici izin istekleri eksik, ya da bu kodu halledilir:

PHP Code

<?php

include_once 'facebook.php';

$facebook = new Facebook(array(
    'appId'  => 'xxxxxxxxxxxxxxxxxx',
    'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
    'cookie' => true
));

$session = $facebook->getSession();

if (!$session) {
    $url = $facebook->getLoginUrl(array(
        'canvas' => 1,
        'fbconnect' => 0
    ));
    echo "<script type='text/javascript'>top.location.href = '$url';</script>";

} else {
    try {
        $uid = $facebook->getUser();
        $me = $facebook->api('/me');
        $updated = date("l, F j, Y", strtotime($me['updated_time']));
        echo "Hello " . $me['name'] . "<br />";
        echo "You last updated your profile on " . $updated;

        $connectUrl = $facebook->getUrl(
          'www',
          'login.php',
          array_merge(array(
            'api_key'         => $facebook->getAppId(),
            'cancel_url'      => 'http://www.test.com',
            'req_perms'       => 'publish_stream',
            'display'         => 'page',
            'fbconnect'       => 1,
            'next'            => 'http://www.test.com',
            'return_session'  => 1,
            'session_version' => 3,
            'v'               => '1.0',
          ), $params)
        );

        $result = $facebook->api(
            '/me/feed/',
            'post',
            array('access_token' => $facebook->access_token, 'message' => 'Playing around with FB Graph..')
        );

    } catch (FacebookApiException $e) {
        echo "Error:" . print_r($e, true);
    }
}
?>

0 Cevap