1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Cannot resolve host "api.gitter.im"

Discussion in 'Development' started by TheDiamondYT, Mar 5, 2017.

  1. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    Im making a plugin and using unirest-php library.

    When i try to get json from a url Unirest gives a Cannot resolve host except, yet the host is working.

    PHP:
    use Unirest\Request;
    use 
    Unirest\Response;
    use 
    Unirest\Method;

    class 
    Gitter {

        const 
    API_URL "https://api.gitter.im/v1";
        const 
    STREAM_URL "https://stream.gitter.im/v1";

        public static function 
    getJSON($path) {
            return 
    Request::get("https://api.gitter.im/v1/", array("Accept" => "application/json"));
        }
    }
    Maybe i should include unirest using miner?
     
  2. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    This is a pocketmine problem because it works if i run from the command line.
     
  3. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    i am suspecting whatever handle Request::get() fail to resolve the domain somehow
     
  4. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    But i created a php script, ran from command line and it worked
     
  5. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    So it seems to be the php binary im using, ill try a different one
     
  6. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    You could try using cURL, like in \pocketmine\utils\Utils::getURL() if you don't do already.
     
  7. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    Its definitely the PHP binary im using. Could you attach a PHP 7 binary please? It has to be a single binary because im using an Android.
     
  8. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    What's wrong with simply using json_decode(Utils::getURL())?
     
  9. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    I tried using cURL, but still could resolve hostname. However I went on termux and installed the php package using apt (yes, all on an android device) then ran the script using that php binary and it worked.
    However the php used in termux isint a single binary file and is specifically setup for termux, so I can't use that for pocketmine unfortunately.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.