Search
 
SCRIPT & CODE EXAMPLE
 

PHP

post json php

$data = json_decode(file_get_contents('php://input'), true);
print_r($data);
echo $data["operacion"];
Comment

php get post json data

$data = json_decode(file_get_contents('php://input'), true);
Comment

php send json post

$url = "your url";    
$content = json_encode("your data to be sent");

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,
        array("Content-type: application/json"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);

$json_response = curl_exec($curl);

$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ( $status != 201 ) {
    die("Error: call to URL $url failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));
}


curl_close($curl);

$response = json_decode($json_response, true);
Comment

json get/post request in php

<?php
  $json = '{
      "title": "PHP",
      "site": "GeeksforGeeks"
  }';
  $data = json_decode($json);
  echo $data->title;
  echo "
";
  echo $data->site;
?>
Comment

PREVIOUS NEXT
Code Example
Php :: how to get just the first row from a table in laravel 
Php :: check the ajax request in laravel 
Php :: invalid datetime format laravel 
Php :: laravel validation unique email except self 
Php :: users not having any role laravel spatie 
Php :: php extract last n words of string 
Php :: regex get text between braces 
Php :: wp shortcode 
Php :: how to fix PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted 
Php :: Class "AppHttpControllersAdminController" not found in laravel 8 
Php :: how to get event dates on change in datetimepicker with laravel livewire 
Php :: run xampp application on windows startup 
Php :: php Convert String containing commas to array 
Php :: update laravel .env variables dynamically 
Php :: php compute price less discount 
Php :: unique array 
Php :: convert scientific notation to decimal php 
Php :: print asociative array php 
Php :: php day of week full name 
Php :: laravel order by numbers 
Php :: symfony migration down 
Php :: remove string after comma in php 
Php :: laravel global scope 
Php :: wp plugins action link 
Php :: php mongodb 
Php :: string compare in php 
Php :: wp_query post by category taxonomy 
Php :: explode php all values to int 
Php :: php submit form in new tab 
Php :: php comment 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =