Android Question download and return a webpage by server

Discussion in 'Android Questions' started by mohsen nasrabady, May 12, 2015.

  1. mohsen nasrabady

    mohsen nasrabady Active Member Licensed User

    hi i have a vps windows server 2008 i installed php on it
    i want use httputils2 or http or some method to tell server a link of a webpage
    and server download that and return utf-8 of the webpage to the user b4a
    i konw httputils2 download method can do this directly
    but some webpage in my country very slow like google image
    i want solve this problem by server

    i found this code on the web
    how can i use it i am new in webserver
    if this code wrong tell me tnx alot
    Code:
    function get_url_contents($url){
            $crl = curl_init();
            $timeout = 
    5;
            curl_setopt ($crl, CURLOPT_URL,$url);
            curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 
    1);
            curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
            $ret = curl_exec($crl);
            curl_close($crl);
            
    return $ret;
    }
     
  2. DonManfred

    DonManfred Expert Licensed User

    See httputils tutorials.
    Just "Download the $url" and get the result in Jobdone
     
  3. mohsen nasrabady

    mohsen nasrabady Active Member Licensed User

    i know but i need server do this because some foreign url in my country very slow download
    but my server is in TEHRAN and can download fast google image pages
     
  4. DonManfred

    DonManfred Expert Licensed User

    Sorry

    Maybe i did not understand correctly what exactly the problem is.

    Try to describe it more clearly (and a better english?).
    Maybe put example links what exactly you mean.
     
  5. mohsen nasrabady

    mohsen nasrabady Active Member Licensed User

    Code:
    J.download("http://www.google.com/search?q="&gname&"%20psx%20screenshot&ie=UTF-8&hl=en&tbm=isch")
    J.GetRequest.SetHeader(
    "User-Agent""Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0")
    i am using this code to download a page from google image
    for some problem i want my server do this and return result like httputils2
     
  6. mohsen nasrabady

    mohsen nasrabady Active Member Licensed User

    Code:
    <?php
    $geturl = $_GET[
    "geturl"];

    function get_url_contents($url){
            $crl = curl_init();
            $timeout = 
    5;
            curl_setopt ($crl, CURLOPT_URL,$url);
            curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 
    1);
            curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
            $ret = curl_exec($crl);
            curl_close($crl);
            
    return $ret;
    }

    $returned_content = get_url_contents($geturl);
    ?>
    this is the of php page
    how can send string of url to this page?
     
    Last edited: May 12, 2015
Loading...
  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.
    Dismiss Notice