Facebook.class.php (936B)
1 <?php 2 3 class Facebook 4 { 5 public $config; 6 public $debug; 7 8 public $url; 9 public $shortUrl; 10 public $text; 11 public $subject; 12 13 14 public function push() 15 { 16 require_once('network/facebook/facebook.php'); 17 18 $facebook = new FacebookApi( array('appId'=>$this->config['app_id'],'secret'=>$this->config['app_secret']) ); 19 $facebook->api_client->session_key = $this->config['session_key']; 20 21 $text = strlen($this->text)>100 ? substr($this->text,0,100).' ...' : $this->text; 22 23 $attachment = array('message' => $this->config['praefix_text'].' '.$this->subject, 24 'name' => $this->subject, 25 'link' => $this->url, 26 'description' => $text 27 ); 28 $attachment['access_token'] = $this->config['access_token']; 29 30 if(!($sendMessage = $facebook->api('/jan.dunkerbeck/feed/','post',$attachment))){ 31 $errors= error_get_last(); 32 echo "Facebook publish error: ".$errors['type']; 33 echo "<br />\n".$errors['message']; 34 } 35 36 } 37 } 38 ?>