Answers for "php api header json"

PHP
6

php header json

header('Content-Type: application/json');
echo json_encode($data);
Posted by: Guest on March-03-2021
0

php api call with headers

<?php
$options = array(
  'http'=>array(
    'method'=>"GET",
    'header'=>"CustomHeader: yay\r\n" .
              "AnotherHeader: test\r\n"
  )
);
$context=stream_context_create($options);
$data=file_get_contents('http://www.someservice.com/api/fetch?key=1234567890',false,$context);
?>
Posted by: Guest on October-25-2021

Browse Popular Code Answers by Language