Android Question download and return a webpage by server

mohsen nasrabady

Active Member
Licensed User
Longtime 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
B4X:
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;
}
 

DonManfred

Expert
Licensed User
Longtime User
See httputils tutorials.
Just "Download the $url" and get the result in Jobdone
 
Upvote 0

mohsen nasrabady

Active Member
Licensed User
Longtime 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
 
Upvote 0

mohsen nasrabady

Active Member
Licensed User
Longtime User
B4X:
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
 
Upvote 0

mohsen nasrabady

Active Member
Licensed User
Longtime User
B4X:
<?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:
Upvote 0
Top