Source Code:
(back to article)
<?php $options = [ 'ssl' => [ 'verify_peer' => false, 'verify_peer_name' => false, ], ]; $context = stream_context_create($options); $url = 'https://jsonplaceholder.typicode.com/posts/1'; $response = file_get_contents($url, false, $context); $data = json_decode($response, true); echo 'Title: ' . $data['title'] . PHP_EOL; echo 'Body: ' . $data['body'] . PHP_EOL;
Result:
Report an issue