Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   Formatting JSON Request in PHP (https://www.warriorforum.com/programming/1244829-formatting-json-request-php.html)

alanwaston 26th December 2016 01:30 AM

Formatting JSON Request in PHP
 
Hi,

I am returning data via an API using JSON and want to format this so that I can display individual bits of data. At present, I just get the whole chunk of data returned and cannot figure out how to format this. Can anyone help please?

<?php

function curl_request(){

$headers = array(
'Content-type: application/JSON',
'Authorization: basic ' . base64_encode('######'.'+'.'#############'.':'.'## ############'),
);
$ch = curl_init();
curl_setopt ($ch, CURLOPT_CAINFO, "D:\Plesk\VHOSTS\plustwodesign.com\bournetown.co.u k\cacert.pem");
curl_setopt($ch, CURLOPT_URL, 'https://api-eu.myconnectwise.net/v2017_1/apis/3.0/service/tickets/13024');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$json = curl_exec($ch);

$input = json_decode($json);

//return $input->summary; //This doesn't work

curl_close ($ch);

}?>
_________________________________________
Relax: bad things ringtone, instrumental ringtones, free ringtone

gayanw 26th December 2016 02:03 AM

RE: Formatting JSON Request in PHP
 
var_dump the input, so someone could help.

var_dump($input);

David Beroff 30th December 2016 11:47 PM

Re: Formatting JSON Request in PHP
 
See: PHP: json_decode - Manual

Pava 1st January 2017 02:14 PM

Re: Formatting JSON Request in PHP
 
Please make a var_export what you got and post here
PHP: var_export - Manual


All times are GMT -6. The time now is 03:15 PM.