How to convert a command line cUrl to PHP cUrl

后端 未结 1 940
囚心锁ツ
囚心锁ツ 2021-01-26 09:38

I was trying to publish messages from PHP and I need to convert the following command into a PHP cURL:

  curl -X PUT --data-binary \"Hello World\" http://eclipse         


        
相关标签:
1条回答
  • 2021-01-26 10:01
        $data = "Hello World";
        $ch = curl_init('http://eclipse.mqttbridge.com/test');
    
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    
        $response = curl_exec($ch);
    
    0 讨论(0)
提交回复
热议问题