PHP Curl POST方法

I am submitting form on a URL using CURL but getting no response and not getting any curl error.

Using following parameters:

  • $param variable contains an array
  • $accept variable contain value "application/vnd.citrix.g2wapi-v1.1+json"
  • $contentType contains value "application/json"

.

<?php
function httpPost($url,$params,$accept,$contentType)
{
   try{
        $post_data=http_build_query($params);
        //print_r($post_data);

        //  Initiate curl
        $ch = curl_init();

        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

        // Set the url
        curl_setopt($ch, CURLOPT_URL,$url);

        curl_setopt($ch,CURLOPT_POST, true);
        curl_setopt($ch,CURLOPT_POSTFIELDS, $post_data);

        // Will return the response, if false it print the response
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        curl_setopt($ch, CURLOPT_HEADER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        "Accept:".$accept,
        "Content-Type:".$contentType
        ));

        // Execute
        $result=curl_exec($ch);

        if ($result==false)
        {
            print_r('Curl error: ' . curl_error($result));
        }

        // Closing
        curl_close($ch);

        // Will dump a beauty json :3
        var_dump(json_decode($result, true));
    } // end try

    catch(Exception $e){
        echo $e->getMessage();
        return $e->getMessage();
    }

} // end httpPost
?>