+ Reply to Thread
Results 1 to 2 of 2

Thread: Исходящие соединения

  1. #1
    Junior Member Customer is on a distinguished road
    Join Date
    Jan 2012
    Posts
    4

    Исходящие соединения

    Добый день,

    Задача: Прекрутить к phpbb скрипты, которые будут связываться с API сервером https://api.eveonline.com/ передавать туда 2 строки и получать оттуда интересующие параметры. Далее на основании полученных от API данных, пользователю на форуме будет присваиваться группа, изменяться ник и тд.

    Скрипт где требуется исходящее соединение:
    <?php
    require_once 'config.inc.php';
    header('Content-type: application/json');
    if (empty($_POST['Key_ID']) or empty($_POST['Key_Ver_Code']) or !is_numeric($_POST['Key_ID']) or !ctype_alnum($_POST['Key_Ver_Code'])) {
    die(json_encode(array('error' => 'API info is missing or incorrectly formatted.')));
    }
    $characters = simplexml_load_file('https://api.eveonline.com/account/APIKeyInfo.xml.aspx?keyID=' . $_POST['Key_ID'] . '&Vcode=' . $_POST['Key_Ver_Code'])
    or die(json_encode(array('error' => 'Error connecting to EVE API server.')));
    $api_url = 'https://api.eveonline.com/account/APIKeyInfo.xml.aspx?keyID=' . $_POST['Key_ID'] . '&Vcode=' . $_POST['Key_Ver_Code'];
    if (extension_loaded('curl')) {
    $api_handle = curl_init($api_url);
    curl_setopt($api_handle, CURLOPT_RETURNTRANSFER, TRUE);
    if (!($api_xml = curl_exec($api_handle)) or curl_getinfo($api_handle, CURLINFO_HTTP_CODE) != 200) {
    die(json_encode(array('error' => 'Error getting API data from EVE server.')));
    }
    curl_close($api_handle);
    }
    else {
    $api_xml = file_get_contents($api_url) or die(json_encode(array('error' => 'Error getting API data from EVE server.')));
    }
    $characters = simplexml_load_string($api_xml);
    if (isset($characters->error) and substr((string) $characters->error->attributes()->code, 0, 1) == 2) {
    die(json_encode(array('error' => 'Authentication failed for this key.')));
    }
    if (!isset($characters->result->key->rowset->row)) {
    die(json_encode(array('error' => 'The character list could not be gathered for this key at this time.')));
    }
    if (((int) $characters->result->key->attributes()->accessMask & $config['Minimum Access Mask']) != $config['Minimum Access Mask']) {
    die(json_encode(array('error' => 'This key does not allow the minimum access options chosen by your admin. Use the link on the registration page to create a key with the correct access level.')));
    }
    if ($config['Account Key Required'] and (string) $characters->result->key->attributes()->type != 'Account') {
    die(json_encode(array('error' => 'Your admin requires an account key, but this is a character-specific key. Choose All under Character when creating.')));
    }
    foreach($characters->result->key->rowset->row as $row) {
    if (array_key_exists((string) $row->attributes()->corporationID, $config['Corps'])) {
    $response['names'][] = (string) $row->attributes()->characterName;
    }
    }
    if (empty($response['names'])) {
    die(json_encode(array('error' => 'No characters in configured corps. were found with this key.')));
    }
    if ((string) $characters->result->key->attributes()->expires != '') {
    $response['warnings'][] = <<<EOL
    Your key will work, but as it has a set expiration date, you will lose your access when it expires. If you want to correct this, you don't need to make a new key. You can simply update the one you already made to not expire.
    EOL;
    }
    echo json_encode($response);
    ?>
    Пробовал этот скрипт на бесплатных хостингах с открытыми исходящими соединениями - работает (но там нет cron ) Подозреваю что проблема именно в этом.
    Дополнительная информация по скрипту: Teamspeak and phpBB Forums EVE Online API Registration System

    Вопрос:
    Можно ли как-нибудь реализовать эту задумку на бесплатном Host1Free?
    Например открыть исходящие соедиенния моему акаунту, хотябы только к api.eveonline.com

    Юзернейм nfc
    NFC Forum &bull; Главная страница
    Last edited by Customer; 01-16-2012 at 09:18 PM.

  2. #2
    Super Moderator Amator is on a distinguished road Amator's Avatar
    Join Date
    Sep 2010
    Location
    Kiev, Ukraine
    Posts
    1,463

    Re: Исходящие соединения

    Здравствуйте! На бесплатном хостинге данный функционал недоступен.
    Прочитайте перед созданием темы
    No support via PM - forum is for support.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34