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

PhP download string from url

Discussion in 'Development' started by Defications2po, May 30, 2021.

  1. Defications2po

    Defications2po Witch

    Messages:
    51
    Uh i was wondering if i could check a string from a url in php. I've used something similar to this in c++ and i was wondering if i could get a sneak peak of what it would look like in php. And before you ask no i have not tried to do it because i simply dont know where to start i have not touched php in 3 years now. And for those who dont understand what i am in need of i can give an example basically i want to use php to check my website https://duece-aim.000webhostapp.com/status.txt and see if the string is "1.0" and if it is "1.0" the code continues etc.
     
  2. Axon

    Axon Zombie

    Messages:
    276
    Check out the Internet Documentation, you can use `getURL` to fetch a page.
    Then you can convert the string to json.
    Internet Documentation: https://jenkins.pmmp.io/job/PocketM...1b/classpocketmine_1_1utils_1_1_internet.html
    Example:
    PHP:
    function fetchJson(string $url){
                
    $data = \pocketmine\utils\Internet::getURL($url); // This will get the data on the url
                
    $jsondata json_decode($data); // Convert string to URL
                
    return $jsondata// Returns the Data
            
    }
    PHP:
    $url "https://gist.githubusercontent.com/ErikPDev/e6997ead97591d4d1c703efec26f82af/raw/c7de5291dcdbde8ecb70ed40acadd4e5f0d51557/file.json"// URL
    var_dump$this->fetchJson($url) );
     
    Agent and Defications2po like this.
  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.