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 array search blade 
Php :: epoch to date php 
Php :: symfony form submit on refresh 
Php :: How to use Query builder with eloquent in Laravel 8? 
Php :: CHECKING IF FILE IS EMPTY IN PHP 
Php :: execute php mysql securely 
Php :: laravel adding condition to relation 
Php :: laravel import xml to database 
Php :: file get content php post 
Php :: check if custom post type exists 
Php :: laravel factory pass parameter 
Php :: clear cache without using composer in laravel 8 
Php :: datatables 
Php :: defining route through controller 
Php :: in date function + 1 month and - 1 day in php 
Php :: command to create middleware in laravel 
Php :: laravel how to nested foreach 
Php :: WordPress Plugin Definition 
Php :: is legged in wodpress 
Php :: laravel migration int length 
Php :: php gravity forms display 
Php :: laravel migrate error default character 199 boot 
Php :: comment blade php 
Php :: Detect the page realod in php 
Php :: change wordpress viewport 
Php :: wc php get acf fields product category 
Php :: php artisan preset bootstrap 
Php :: how to show login user name in php 
Php :: eloquent firstorcreate 
Php :: magento 2 remove order 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =