コード例 #1
0
ファイル: PushConnection.php プロジェクト: korejwo/michales
 /**
  * Konstruktor PushConnection - przeprowadza autoryzację
  *
  * @param int $botGGNumber numer GG bota
  * @param string $userName login
  * @param string $password hasło
  */
 public function __construct($botGGNumber = NULL, $userName = NULL, $password = NULL)
 {
     if (empty(self::$lastAuthorization) || !self::$lastAuthorization->isAuthorized() || $botGGNumber != self::$lastGg && $botGGNumber !== NULL) {
         if ($userName === NULL && self::$BOTAPI_LOGIN !== NULL) {
             $userName = self::$BOTAPI_LOGIN;
         }
         if ($password === NULL && self::$BOTAPI_PASSWORD !== NULL) {
             $password = self::$BOTAPI_PASSWORD;
         }
         self::$lastGg = $botGGNumber;
         self::$lastAuthorization = new BotAPIAuthorization(self::$lastGg, $userName, $password);
     }
     $this->gg = self::$lastGg;
     $this->authorization = self::$lastAuthorization;
 }
コード例 #2
0
ファイル: push.php プロジェクト: GGNetwork/BotAPI
<?
require_once(dirname(__FILE__).'/../PushConnection.php');

$M=new MessageBuilder();
$M->setRecipients(array(12345,23456,34567,45678));

switch (rand(1, 4)) {
case 1: $M->addText('1. Zwykły tekst bez formatowania w kolorze pomarańczowym', FORMAT_NONE, 255, 165, 0); break;
case 2: $M->addText('2. Tekst pogrubiony, pochylony i podkreślony', FORMAT_BOLD_TEXT | FORMAT_ITALIC_TEXT | FORMAT_UNDERLINE_TEXT); break;
case 3: $M->addText('3. Tekst podkreślony w kolorze czerwonym z obrazkiem', FORMAT_UNDERLINE_TEXT, 255, 0, 0)->addImage(dirname(__FILE__).'/gg.jpg'); break;
case 4: $M->addText('4. Zwykły tekst bez formatowania'); break;
}

$P=new PushConnection(1234567, 'login', 'hasło');
$P->push($M);
コード例 #3
0
ファイル: bot.php プロジェクト: marsoltys/ggbotsdk
<?php

require_once 'MessageBuilder.php';
require_once 'PushConnection.php';
PushConnection::$BOTAPI_LOGIN = '******';
PushConnection::$BOTAPI_PASSWORD = '******';
$P = new PushConnection(123456);
$M = new MessageBuilder();
switch ($HTTP_RAW_POST_DATA) {
    case "kot":
        $M->addText('Oto kot:');
        $M->addImage('kot.jpg');
        break;
    default:
        $M->addBBcode('A to jest GG:');
        $M->addImage('gg.png');
}
$M->reply();
コード例 #4
0
ファイル: MessageBuilder.php プロジェクト: marsoltys/ggbotsdk
 /**
  * Dodaje obraz do wiadomości
  *
  * @param string $fileName nazwa pliku w formacie JPEG
  *
  * @return MessageBuilder this
  */
 public function addImage($fileName, $isFile = IMG_FILE)
 {
     if ($isFile == IMG_FILE) {
         $fileName = file_get_contents($fileName);
     }
     $crc = crc32($fileName);
     $hash = sprintf('%08x%08x', $crc, strlen($fileName));
     if (empty(PushConnection::$lastAuthorization)) {
         throw new Exception('Użyj klasy PushConnection');
     }
     $P = new PushConnection();
     if (!$P->existsImage($hash)) {
         if (!$P->putImage($fileName)) {
             throw new Exception('Nie udało się wysłać obrazka');
         }
     }
     $this->format .= pack('vCCCVV', strlen($this->text), 0x80, 0x9, 0x1, strlen($fileName), $crc);
     $this->addRawHtml('<img name="' . $hash . '">');
     return $this;
 }
コード例 #5
0
ファイル: PushConnection.php プロジェクト: marsoltys/ggbotsdk
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see<http://www.gnu.org/licenses/>.
 *******/
namespace marsoltys\ggbotsdk;

define('CURL_VERBOSE', false);
// zmienić na true, jeśli chce się uzyskać dodatkowe informacje debugowe
define('STATUS_AWAY', 'away');
define('STATUS_FFC', 'ffc');
define('STATUS_BACK', 'back');
define('STATUS_DND', 'dnd');
define('STATUS_INVISIBLE', 'invisible');
PushConnection::$BOTAPI_LOGIN = '';
PushConnection::$BOTAPI_PASSWORD = '';
/**
 * @brief Klasa reprezentująca połączenie PUSH z BotMasterem.
 * Autoryzuje połączenie w trakcie tworzenia i wysyła wiadomości do BotMastera.
 */
class PushConnection
{
    /**
     * Obiekt autoryzacji
     *
     * Typ BotAPIAuthorization
     */
    public static $BOTAPI_LOGIN = NULL;
    public static $BOTAPI_PASSWORD = NULL;
    static $lastGg;
    static $lastAuthorization;
コード例 #6
0
ファイル: bot.php プロジェクト: marsoltys/ggbotsdk
<?php

require_once 'PushConnection.php';
$P = new PushConnection(123456, '*****@*****.**', 'hasło');
// autoryzacja
$P->setStatus('Mój nowy opis', STATUS_AWAY);
コード例 #7
0
ファイル: status.php プロジェクト: GGNetwork/BotAPI
<?
require_once(dirname(__FILE__).'/../PushConnection.php');

$P=new PushConnection(123456, 'login', 'hasło');
$P->setStatus('test opisu', STATUS_FFC);
sleep(5);
$P->setStatus('', STATUS_BACK);