PHP to get password-protected REST datasnap information -
i have following code information datasnap server:
<?php $username = username $password = password $service_url = 'http://200.206.17.34:81/datasnap/rest/tservermethods1/blogin/'; $curl = curl_init($service_url); curl_setopt($curl, curlopt_returntransfer, true); curl_setopt($curl, curlopt_httpauth, curlauth_any); curl_setopt($curl, curlopt_userpwd, $username . ":" . $password); $curl_response = curl_exec($curl); echo $curl_response; if ($curl_response === false) { $info = curl_getinfo($curl); curl_close($curl); die('error occured during curl exec. additional info: ' . var_export($info)); } curl_close($curl); $decoded = json_decode($curl_response); if (isset($decoded->response->status) && $decoded->response->status == 'error') { die('error occured: ' . $decoded->response->errormessage); } echo 'response ok!'; var_export($decoded->response); ?>
what when run is:
array ( 'url' => 'http://200.206.17.34:81/datasnap/rest/tservermethods1/blogin/', 'content_type' => null, 'http_code' => 0, 'header_size' => 0, 'request_size' => 0, 'filetime' => -1, 'ssl_verify_result' => 0, 'redirect_count' => 0, 'total_time' => 0, 'namelookup_time' => 0.0002249999999999999938417316602823348148376680910587310791015625, 'connect_time' => 0, 'pretransfer_time' => 0, 'size_upload' => 0, 'size_download' => 0, 'speed_download' => 0, 'speed_upload' => 0, 'download_content_length' => -1, 'upload_content_length' => -1, 'starttransfer_time' => 0, 'redirect_time' => 0, 'redirect_url' => '', 'primary_ip' => '200.206.17.34', 'certinfo' => array ( ), )error occured during curl exec. additional info:
what doing wrong?
--edit:
i can connect address both browser , wget.
the data curl_info indicates problem connecting server, e.g., "'content_type' => null, 'http_code' => 0", etc.
try inserting print curl_error($curl)
before closing the $curl handler in first if
statement more information.
Comments
Post a Comment