2011-07-31 94 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

謝謝..我用「全球」:) –