I want to get results from this API as specified. But from what I know, I have tried to write some codes but it seems it doesn't work. I there any one can help me?

here is the API
http://1XX.XXX.XX.66:4848/SmartMeter/vms/credit?meterNumber=51751100044&amount=10&method=0&referenceNumber=12345678&return=JSON

Request Parameters -
meterNumber: Meter Number(Like 51931000049)
amount: Amount(like 10 kWh,10 M³) or Currency( 10 $)
method: 0 means Amount, 1 means Currency
referenceNumber: a unique number to synchronize the request and
response(Like 12345678)
return: JSON, XML, TEXT (Return format)

{
    'code':'000',
    'description':'The command executed successfully',
    'meterNumber':'51931000049',
    'token':'19654220842452620628',
    'address':'china, jianshu, shuzhou',
    'referenceNumber':'12345678'
}

it doesn't work

You need to be more specific than that. What code do you use? What fails? What did you expect?

You need to be more specific than that. What code do you use? What fails? What did you expect?

Here is my codes

$curl=curl_init();        curl_setopt($curl,CURLOPT_URL,"http://1XX.XXX.XX.XX:4848/SmartMeter/vms/credit?meterNumber=51751100044&amount=10&method=0&referenceNumber=12345678&return=JSON");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $result=curl_exec($curl);
    curl_close($curl);
    print_r($result);

What fails? What did you expect?

Answer those too, please. I have no idea if you need to login to the API, or what else might be required. What is the URL of the API documentation?

I got empty results, and I expect to get the following results

{
    'code':'000',
    'description':'The command executed successfully',
    'meterNumber':'51931000049',
    'token':'19654220842452620628',
    'address':'china, jianshu, shuzhou',
    'referenceNumber':'12345678'
}

I have no idea if you need to login to the API, or what else might be required. What is the URL of the API documentation?

I have no idea if you need to login to the API, or what else might be required. What is the URL of the API documentation?

Ok the issue is not to login to the API my friend,. According to API description, no login required, the only thing here is to use that API link with that parameters to return the values in JSON format as shown here

Link: http://1XX.XXX.XX.66:4848/SmartMeter/vms/credit?meterNumber=51751100044&amount=10&method=0&referenceNumber=12345678&return=JSON

Returned values:

{
    'code':'000',
    'description':'The command executed successfully',
    'meterNumber':'51931000049',
    'token':'19654220842452620628',
    'address':'china, jianshu, shuzhou',
    'referenceNumber':'12345678'
}

May be can I have your email address so I can forward the API document to you my friend?

I got empty results, and I expect to get the following results

Did you get an empty json result, or was there an error somewhere?

Is there a test call you can do that returns a result?

May be can I have your email address so I can forward the API document to you my friend?

No.

Did you get an empty json result, or was there an error somewhere? Is there a test call you can do that returns a result?

Yes my frend I get an empty json results

Is there any other call that DOES give you results?

No other call my friend

If not one call yields results, better check with the provider of the API.

Have you tried with SoapUI?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.