facebook应用程序的功能问题?

时间:2011-07-31 22:02:57

标签: php facebook api

这是我的gonderdb.class.php:

   <?php 
Class GonderDB Extends DB
{
    public function validate_user($id)
    {
        $sql = "SELECT id,facebookid FROM users WHERE facebookid='$id'";
        $query = mysql_query($sql,parent::BaglanDB());
        $count = mysql_now_rows($count);

        if ($count<1)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    public function get_user($id,$burc)
    {
        $sql = "SELECT * FROM users WHERE facebookid='$id' ";
        $query = mysql_qıuery($sql,parent::BaglanDB());

        while ($rs = mysql_fetch_assoc($query))
        {
            $data[] = $rs;
        }

        return $data;
    }

    public function publish_post_first($user)
    {
            try 
            {
                $array = array('link' => 'http://apps.facebook.com/gunlukburcpaylas/',
                'description' => 'Profilinizde günlük burcunuzu otomatik paylaşın..'
                );

                if ($facebook->api('/me/feed/', 'post', $array))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            } 
            catch (FacebookApiException $e) 
            {
                    return $e->getMessage();
            }
    }


    function publish_post_everyday($fbid = false, $aciklama = false)
    {
        try 
        {
            $array = array('link' => 'http://apps.facebook.com/gunlukburcpaylas/',
            'description' => $aciklama
            );

            if ($statusUpdate = $facebook->api('/' . $fbid . '/feed/', 'post', $array))
            {
                return true;
            }
            else
            {
                return false;
            }
        } 
        catch (FacebookApiException $e) 
        {
                return $e->getMessage();
        }
    }

}

?>

这是我的index.php:

<?php
ob_start();

require 'src/facebook.php';

$facebook = new Facebook(array(
    'appId'  => '258561857493875',
    'secret' => 'jjjklpkpokpokpojpoj',
    'cookie' => true
));
$user = $facebook->getUser();


require 'classes/db.class.php';
require 'classes/ekledb.class.php';
require 'classes/gonderdb.class.php';
$gonder = new GonderDB();
$ekle = new EkleDB();

if($user) 
{ 
   echo $gonder->publish_post_first(); // DONT WORK <-----
}
else
{
    $url = 'https://www.facebook.com/dialog/oauth?client_id=258561857493875&redirect_uri=http://apps.facebook.com/gunlukburcpaylas/&scope=email,read_stream,publish_stream,offline_access';
    echo "<center><a href='". $url ."'><h1>Giriş yap</h1></a></center>";
}


?>

$ gonder-&gt; publish_post_first功能不起作用..为什么? 我无法看到错误我应该如何工作?

1 个答案:

答案 0 :(得分:1)

您需要传递$user

因此,$gonder->publish_post_first();应为$gonder->publish_post_first($user);