我有以下代码从DataSnap服务器获取一些信息:
<?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);
?>
运行时我得到的是:
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:
我做错了什么?
- 编辑:
我可以使用浏览器和wget连接到该地址。
答案 0 :(得分:0)
来自curl_info的数据表示连接到服务器时出现问题,例如“'content_type'=&gt; NULL,'http_code'=&gt; 0”等。
在关闭第一个tweetword = (['a','b','c','a'],['a','e','f'],['d','g'])
count_total_a = {}
for t in tweetword:
for word in tweetword:
if word not in count_total_a:
count_toal_a[word] = len(t)
if word in count_total_a:
count_total_a[word] += len(t)
'''the result I get is not correct coz it counts the first list twice'''
语句中的$ curl处理程序之前尝试插入print curl_error($curl)
以获取更多信息。