コード例 #1
0
ファイル: nagnot.php プロジェクト: richadams/nagnot
include_once "xmpphp/XMPP.php";
output("Received instruction - (im:" . $INPUT['im'] . ",email:" . $INPUT['email'] . ",subject:" . $INPUT['subject'] . ",message:" . $INPUT['message'] . ")");
$im_sent = false;
// Try an IM
try {
    // Attempt to connect and get user roster.
    $conn = new XMPPHP_XMPP($XMPP['server'], $XMPP['port'], $XMPP['username'], $XMPP['password'], $XMPP['resource'], $XMPP['domain']);
    output("Connecting to IM server....");
    $conn->connect();
    $conn->processUntil('session_start');
    $conn->presence();
    output("Retrieving roster....");
    $conn->getRoster();
    $roster = $conn->roster;
    // No specific event to signify end, so use timer instead. 3s should be enough.
    $conn->processTime(3);
    // Determine status of user.
    $active = $roster->getPresence($INPUT['im']);
    output("User " . $INPUT['im'] . " state is '" . $active['show'] . "'....");
    $online = in_array($active['show'], $CONFIG['notify_status']);
    // If they're online, then we're all good.
    if ($online) {
        output("Notifying user via IM....");
        $conn->message($INPUT['im'], $INPUT['subject'] . "\n" . $INPUT['message']);
        // Wait for an acknowledgement (any message sent back)
        $payload = $conn->processUntil('message', $ACK_TIMEOUT);
        // non-zero payload array length means a message was received
        $im_sent = count($payload);
    }
    $conn->disconnect();
} catch (XMPPHP_Exception $e) {
コード例 #2
0
ファイル: list_contact.php プロジェクト: nyn0x/XMPPHP_LOL
<?php

if (isset($_POST['username'], $_POST['pwd']) & !empty($_POST['username']) & !empty($_POST['pwd'])) {
    //formulaire envoyé, on tente de se connecter
    $username = $_POST['username'];
    $password = $_POST['pwd'];
    $conn = new XMPPHP_XMPP('chat.euw1.lol.riotgames.com', 5223, $username, 'AIR_' . $password, 'xiff', 'pvp.net', $printlog = false, $loglevel = XMPPHP_Log::LEVEL_INFO);
    $conn->autoSubscribe();
    $conn->connect();
    try {
        $payloads = $conn->processUntil(array('session_start', 'roster_received'));
        $conn->presence();
        $conn->processTime(5);
        // now see the results
        $roster = $conn->roster->getRoster();
        //print_r($roster); // you should now see roster array with presence info for each contact
        //le joueur connecté est présent dans sa liste d'amis donc on le supprime
        unset($roster[$conn->jid]);
        //RIP MVC
        ?>
        <section>   

            <div class="bootcards-list">
                <div class="panel panel-default">

                    <div class="panel-body">
                        <h1 class="text-center">Liste de contacts</h1>  
                    </div>                

                    <div class="list-group">