|  |  | 
 |  |  |    } | 
 |  |  |     | 
 |  |  |    function putImage($path) { | 
 |  |  |       $fp = fopen($path, 'r'); | 
 |  |  |       if(!$fp) { | 
 |  |  |          return FALSE; | 
 |  |  |       } | 
 |  |  | 		 | 
 |  |  |       $auth = $this->APIs['Gadu-Gadu']; | 
 |  |  |       $token = $this->getToken(); | 
 |  |  |        | 
 |  |  |       $tok = $this->httpQuery('https://botapi.gadu-gadu.pl/botmaster/putImage/'.$auth['numer'], array( | 
 |  |  |          CURLOPT_HTTPHEADER => array('Content-Type: image/x-any'), | 
 |  |  |          CURLOPT_HTTPHEADER => array( | 
 |  |  |             'Content-Type: image/x-any', | 
 |  |  |             'Expect: ', | 
 |  |  |          ), | 
 |  |  |          CURLOPT_POST => TRUE, | 
 |  |  |          CURLOPT_INFILE => $fp, | 
 |  |  |          CURLOPT_POSTFIELDS => file_get_contents($path), | 
 |  |  |       )); | 
 |  |  |        | 
 |  |  |       if( (string)$tok->status != '0') { | 
 |  |  | 
 |  |  |     * array( 'SendToOffline' => (bool)TRUE/FALSE ) | 
 |  |  |     */ | 
 |  |  |    function sendMessage($toURL, BotMsg $msg, $params = array()) { | 
 |  |  |       if(is_string($toURL)) { | 
 |  |  |          $toURL = array($toURL); | 
 |  |  |       } | 
 |  |  | 		 | 
 |  |  |       if(!is_array($toURL)) { | 
 |  |  |          throw new Exception('Lista adresatów przekazywanych do funkcji BotAPIGG::sendMessage() winna być tablicą.'); | 
 |  |  |       } | 
 |  |  | 		 | 
 |  |  |       $to = array(); | 
 |  |  |       foreach($toURL as $url) { | 
 |  |  |          $url = parse_url($url); | 
 |  |  |          if($url === FALSE) { | 
 |  |  |             continue; | 
 |  |  |          } | 
 |  |  | 			 | 
 |  |  |          if($url['scheme'] != 'Gadu-Gadu') { | 
 |  |  |             continue; | 
 |  |  |          } | 
 |  |  | 
 |  |  |             ), | 
 |  |  |          )); | 
 |  |  |           | 
 |  |  |          // Brak obrazka w cache BotMastera... | 
 |  |  |          if((string)$tok->status == '18') { | 
 |  |  |             $tok = $this->httpQuery('https://'.$token['host'].'/sendMessage/'.$auth['numer'], FALSE, array( | 
 |  |  |             $tok = $this->httpQuery('https://'.$token['host'].'/sendMessage/'.$auth['numer'], array( | 
 |  |  |                CURLOPT_HTTPHEADER => $headers, | 
 |  |  |                CURLOPT_POST => TRUE, | 
 |  |  |                CURLOPT_POSTFIELDS => array( | 
 |  |  | 
 |  |  |        | 
 |  |  |       return TRUE; | 
 |  |  |    } | 
 |  |  | 	 | 
 |  |  |    /** | 
 |  |  |     * Pobiera dane użytkownika z katalogu publicznego. | 
 |  |  |     * @param string|BotUser Numer użytkownika | 
 |  |  |     * @return array|false Tablica z danymi. | 
 |  |  |     */ | 
 |  |  |    function getPublicData($number) { | 
 |  |  |       if($number instanceof BotUser) { | 
 |  |  |          if($number->network != 'gadu-gadu.pl') { | 
 |  |  |             return FALSE; | 
 |  |  |          } | 
 |  |  | 			 | 
 |  |  |          $number = $number->uid; | 
 |  |  |       } | 
 |  |  | 		 | 
 |  |  |       if(!ctype_digit($number)) { | 
 |  |  |          throw new Exception('Numer użytkownika przekazany do funkcji BotAPIGG::getPublicData() jest niepoprawny.'); | 
 |  |  |       } | 
 |  |  | 		 | 
 |  |  |       try { | 
 |  |  |          $data = file_get_contents('http://api.gadu-gadu.pl/users/'.$number.'.xml'); | 
 |  |  |          if(!$data) { | 
 |  |  |             throw new Exception('Nie udało się pobrać danych użytkownika z katalogu publicznego.'); | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       catch(Exception $e) { | 
 |  |  |          throw new Exception('Nie udało się pobrać danych użytkownika z katalogu publicznego.'); | 
 |  |  |       } | 
 |  |  | 		 | 
 |  |  |       libxml_use_internal_errors(); | 
 |  |  |       $data = simplexml_load_string($data); | 
 |  |  |       libxml_clear_errors(); | 
 |  |  | 		 | 
 |  |  |       if(!$data) { | 
 |  |  |          throw new Exception('Dane użytkownika otrzymane z API Gadu-Gadu mają niepoprawny format.'); | 
 |  |  |       } | 
 |  |  | 		 | 
 |  |  |       if(!$data) { | 
 |  |  |          throw new Exception('Dane użytkownika otrzymane z API Gadu-Gadu mają niepoprawny format.'); | 
 |  |  |       } | 
 |  |  | 		 | 
 |  |  | 		 | 
 |  |  |       return (array)$data->users->user; | 
 |  |  |    } | 
 |  |  | } | 
 |  |  | ?> |