Accessing certain ports in server script platform.api.get("host:80") respond to "false"


#1

finally i raised up v8js, now i want to give a get request in scripts but cant find way to get on certain ports, even port 80, see:
var _result = platform.api.get(“https://www.google.com:80”);
throw "ok "+JSON.stringify(_result);

//output {

“message”: “ok false”,

}

it always give false if i indicate port number… any idea ??
i tryed to use options… but of no avail…

Edit: I am using DF 1.9.x


#2

Including the port works fine in my test system.

I notice you’re accessing google via https over port 80. Pretty sure that’s not going to work.

Do you have another URL you could try?


#3

Why not https ?? We have a vpn connection and trying to send get request to the host ip address with certain port, and it is not https, simple http, of course with vpn certificate…
But still we get false reply… Any solution for such cases???


Older bitnami stack for dreamfactory 1.9.4, need v8js
#4

https should work, but not https on port 80. Google will not respond affirmatively.

The majority of web servers are not listening for https traffic on port 80.
Can you explain your situation more clearly?


#5

yeah, you were right, port 80 didnt respond with https !!!
i thought the problem was with the api doc features … our response was in XML form but by default dsp accepted as JSON format so as a result only FALSE was shown instead of all xml tags,

EDIT : even after changing that i got output as

<?xml version="1.0" ?> okfalse 500

just in xml format… i dont know is this related to our VPN connection host reply ot with dsp settings ?? again stuck…


#6

Issue Reopened
We have a VPN connection through linux server, everything works fine, and request-response expectations match if we use just direct browser or command line terminal, but when i try it with server scripting it just returns me false in api docs …
even after changing to xml view i got output as

<?xml version="1.0" ?> okfalse 500

which is just in xml format… i dont know is this related to our VPN connection host reply or with dsp settings ?? again stuck… help pleaseeee

EDIT: maybe we need to add --insecure or -k for not checking certificate, if so, then how to add such options ?


#7

Soooooo, in any case…

After struggling with the source code of DF like vendor/dreamfactory/lib-php-common-platform/src/Scripting/ScriptEngine.php line 549 i found out that the problem is with the curl_options and the function just returned FALSE due to ssl certificate…

after a deep search on php curl docs i found this options useful and got my result :

 function get_web_page( $url,$curl_data ) 
{ 
   $options = array( 
    CURLOPT_RETURNTRANSFER => true,         // return web page 
    CURLOPT_HEADER         => false,        // don't return headers 
    CURLOPT_FOLLOWLOCATION => true,         // follow redirects 
    CURLOPT_ENCODING       => "",           // handle all encodings 
    CURLOPT_USERAGENT      => "spider",     // who am i 
    CURLOPT_AUTOREFERER    => true,         // set referer on redirect 
    CURLOPT_CONNECTTIMEOUT => 120,          // timeout on connect 
    CURLOPT_TIMEOUT        => 120,          // timeout on response 
    CURLOPT_MAXREDIRS      => 10,           // stop after 10 redirects 
    CURLOPT_POST            => 1,            // i am sending post data 
       CURLOPT_POSTFIELDS     => $curl_data,    // this are my post vars 
    CURLOPT_SSL_VERIFYHOST => 0,            // don't verify ssl 
    CURLOPT_SSL_VERIFYPEER => false,        // 
    CURLOPT_VERBOSE        => 1                // 
); 

$ch      = curl_init($url); 
curl_setopt_array($ch,$options); 
$content = curl_exec($ch); 
$err     = curl_errno($ch); 
$errmsg  = curl_error($ch) ; 
$header  = curl_getinfo($ch); 
curl_close($ch); 

 //  $header['errno']   = $err; 
 //  $header['errmsg']  = $errmsg; 
 //  $header['content'] = $content; 
return $header; 
} 

 $curl_data = "var1=60&var2=test"; 
 $url = "https://www.example.com"; 
 $response = get_web_page($url,$curl_data); 

print '<pre>'; 
print_r($response); 
....

Link php curl docs
:sweat_smile: