2011-07-31 45 views
1

这是我gonderdb.class.php:facebook应用程序的功能问题?

<?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-> publish_post_first功能不工作。为什么? 而我不能看到错误我应该如何工作?

+0

你在哪里,你声明类gonder?这里没有显示 – DSchultz

+0

更新........ –

回答

1

您需要通过$user

所以,$gonder->publish_post_first();$gonder->publish_post_first($user);

+0

谢谢..我用“全球”:) –