I wanted to call Web service using POST method and attache the Data values.

Here is my URL : http://api.geonames.org/citiesJSON which takes below data in POST.


How can I Form POST URL and Call POST Web service. Thanks in Advance.

1 Answer 1


I checked with above data but the credit usage exceeds for that user account, I tried with the new account it's working, please find the curl call below,

$ch = curl_init();
    $url = "http://api.geonames.org/citiesJSON";
    curl_setopt($ch,CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, "north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=chez");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $data = curl_exec($ch);

If this answer helpful for you means, accept the answer

  • This is perfect for core PHP.
    – kunj
    May 28, 2018 at 7:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.