How do I use received JSON with PHP -


i'm reading integration api , says send requests in format:

content-type: application/json accept: application/json x-gsc-api-key: lrds8nfsvtmhd8sc1234  {    "name"      : "testuser",   "password"  : "098f6bcd4621d373cade4e832627b4f6",   "reference" : "b86de61-af20-4c47-af9a-6f2edeebc4fe"  } 

i want server requests php. know other posts ask along same lines, sending request via ajax method. don't know method request going sent.

can reference variables $_post['name'] , $_post['password'] values? or need call json_decode($_post)?

is information enough write php script server request?

any appreciated.

no, cannot use $_post directly. have manually extract response body, json_decode , work on results. it's easy do:

$data = json_decode(file_get_contents('php://input'));  echo $data->name; 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -