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 :: laravel join with multiple conditions 
Php :: convert json object to array in php 
Php :: php support block-level scope 
Php :: foreach loop in php 
Php :: How to add new column in table laravel 
Php :: disable block editor on widget section wordpress 
Php :: storePublicly laravel with name 
Php :: php subtract seconds from datetime 
Php :: php store log in a text file 
Php :: how to print count query in php 
Php :: array push foreach php 
Php :: how to trim white space array in php 
Php :: laravel websockets onclose 
Php :: laravel php artisan make:controller in subfolder 
Php :: laravel mixed content error 
Php :: laravel validation allow empty array 
Php :: laravel encrypt password 
Php :: Database//Eloquent//Model.php laravel errror array t- string conversion 
Php :: php date strtotime format 
Php :: Artisan::call for all catch clear in laravel 
Php :: Laravel seed timestamps columns 
Php :: how to install multiple php versions ubuntu 
Php :: wp get post author link 
Php :: slp price php 
Php :: if browser url is having domain in it check using php 
Php :: ctrl + d in vscode in phpstorm 
Php :: nl2br php 
Php :: wordpress get custom post type posts 
Php :: make a object php 
Php :: artisan commands in route 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =