我想使用php从cassandraapachenosql下载数据,作为我正在进行的项目的一部分。但我对php还不熟悉。我想登录并从nosqldb中提取json数据。我相信下面的代码实际上是登录的,因为它生成了一个输出“[]”。没有别的,没有成功的信息。我要传递以下参数
networkhierarchyid=3,metertypeid=2
我期望得到以下结果。任何人都可以教我怎么做。
[
{
"MeterLookup_TblRefID": 237,
"NetworkLookup_TblRefID": 3,
"Network_Name": "SS-43 SEWA SCADA (Command Center)",
"Longitude": 57.403547,
"Latitude": 27.366666,
"OnOFfStatus": true
},
{
"MeterLookup_TblRefID": 277,
"NetworkLookup_TblRefID": 4,
"Network_Name": "SS-8 MaySaloon",
"Longitude": 57.406274,
"Latitude": 27.360654,
"OnOFfStatus": true
},
{
"MeterLookup_TblRefID": 798,
"NetworkLookup_TblRefID": 5,
"Network_Name": "SS-1 Al Nasserya Driving School",
"Longitude": 57.404669,
"Latitude": 27.367591,
"OnOFfStatus": true
}
]
这是我的密码:
<?php
$url = 'http://127.0.0.2:9003/TimApp/api/NxtMbl/getdtrloadconsumptiondetails';
//Your username.
$username = 'ApiUser';
//Your password.
$password = 'ApiPass';
//Initiate cURL.
$ch = curl_init($url);
//Specify the username and password using the CURLOPT_USERPWD option.
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
//Tell cURL to return the output as a string instead
//of dumping it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//Execute the cURL request.
$response = curl_exec($ch);
//Check for errors.
if(curl_errno($ch)){
//If an error occured, throw an Exception.
throw new Exception(curl_error($ch));
}
//Print out the response.
echo $response;
?>
暂无答案!
目前还没有任何答案,快来回答吧!