on-internet
← Community

POST JSON with PHP cURL and show JSON response

Stack Overflow ·

I've looked a lot around on Stack Overflow to find an answer to my issue, but simply can't. I'm trying to post the following JSON <?php $data_string = '{ "jsonrpc": "2.0", "method": "login", "id": 1, "params": { "params": { "username": "4321", "password": "1234" } } }'; $ch = curl_init('https://domain.com'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string)) ); $result = curl_ex

Comments

Sign in or sign up to comment and upvote.

No comments yet.