Exemplo n.º 1
0
/**
 * get buddy list directly, wopwhite
 * 
 * @ssic user identification
 * @sid fetion id
 */
function fetion_get_buddy_list_directly($sid, $tunnel)
{
    $buddy_regex = '/.*?\\r\\n\\r\\n(.*)\\s*$/is';
    $arg = '<args><contacts><buddy-lists /><buddies attributes="all" /><mobile-buddies attributes="all" /><chat-friends /><blacklist /></contacts></args>';
    $msg = fetion_sip_create('S fetion.com.cn SIP-C/2.0', array('F' => $sid, 'I' => fetion_next_call(), 'Q' => '1 S', 'N' => 'GetContactList'), $arg);
    fetion_debug("get buddy list...");
    socket_write($tunnel, $msg, strlen($msg));
    // need IMPROVE, should use socket select, but hardcoded as 20 seconds for convenience
    sleep(20);
    $msg = socket_read($tunnel, 4096);
    $matches = array();
    if (!preg_match($buddy_regex, $msg, $matches)) {
        error_log("Fetion Error: No buddy list found");
        return false;
    }
    $buddy_list = simplexml_load_string($matches[1]);
    $buddies = array();
    foreach ($buddy_list->contacts->buddies->buddy as $buddy) {
        $buddies[strval($buddy['uri'])] = strval($buddy['local-name']);
    }
    foreach ($buddy_list->contacts->{'mobile-buddies'}->{'mobile-buddy'} as $buddy) {
        $buddies[strval($buddy['uri'])] = strval($buddy['local-name']);
    }
    return $buddies;
}
Exemplo n.º 2
0
/**
 * get buddy list
 * 
 * @ssic user identification
 * @sid fetion id
 */
function fetion_get_buddy_list($ssic, $sid)
{
    $buddy_regex = '/.*?\\r\\n\\r\\n(.*)' . FETION_SIPP . '\\s*$/is';
    $arg = '<args><contacts><buddy-lists /><buddies attributes="all" /><mobile-buddies attributes="all" /><chat-friends /><blacklist /></contacts></args>';
    $msg = fetion_sip_create('S fetion.com.cn SIP-C/2.0', array('F' => $sid, 'I' => fetion_next_call(), 'Q' => '1 S', 'N' => 'GetContactList'), $arg) . FETION_SIPP;
    fetion_curl_exec(fetion_next_url(), $ssic, $msg);
    $msg = fetion_curl_exec(fetion_next_url(), $ssic, FETION_SIPP);
    $matches = array();
    if (!preg_match($buddy_regex, $msg, $matches)) {
        error_log("Fetion Error: No buddy list found");
        return false;
    }
    $buddy_list = simplexml_load_string($matches[1]);
    $buddies = array();
    foreach ($buddy_list->contacts->buddies->buddy as $buddy) {
        $buddies[strval($buddy['uri'])] = strval($buddy['local-name']);
    }
    foreach ($buddy_list->contacts->{'mobile-buddies'}->{'mobile-buddy'} as $buddy) {
        $buddies[strval($buddy['uri'])] = strval($buddy['local-name']);
    }
    return $buddies;
}