cURL ile API üzerinden Veri Çekme

← LİSTEYE DÖN

Açıklama

Bir REST API servisinden JSON verisi çekmek ve bu veriyi PHP dizisine dönüştürmek için kullanılan profesyonel yöntem.
PHP SOURCE CODE
<?php
$url = "https://jsonplaceholder.typicode.com/posts/1";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
echo $data["title"];?>
Görüntülenme: 45
Ekleyen: Admin