Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 26th Dec 2016, 01:30 AM   #1
Warrior Member
 
Join Date: 2016
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Formatting JSON Request in PHP
Share on: 
fb share twitter share gplus share more share

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

Last edited on 3rd Jan 2017 at 10:16 PM.
alanwaston is offline  
Unread 26th Dec 2016, 02:03 AM   #2
Work for Open Source
 
gayanw's Avatar
 
Join Date: 2016
Posts: 10
Thanks: 5
Thanked 1 Time in 1 Post
Default
RE: Formatting JSON Request in PHP
Share on: 
fb share twitter share gplus share more share

var_dump the input, so someone could help.

var_dump($input);

Last edited on 26th Dec 2016 at 02:05 AM.
gayanw is offline  
Unread 30th Dec 2016, 11:47 PM   #3
Bananas are Yellow!
Registered Member
War Room Member
 
David Beroff's Avatar
 
Join Date: 2013
Location: Wyoming, PA, USA
Posts: 1,046
Thanks: 2,549
Thanked 1,600 Times in 928 Posts
Blog Entries: 4
Default
Re: Formatting JSON Request in PHP
Share on: 
fb share twitter share gplus share more share

See: PHP: json_decode - Manual

Put MY voice on YOUR video: AwesomeAmericanAudio.com
David Beroff is offline  
Unread 1st Jan 2017, 02:14 PM   #4
HyperActive Warrior
 
Pava's Avatar
 
Join Date: 2012
Posts: 148
Thanks: 27
Thanked 9 Times in 6 Posts
Default
Re: Formatting JSON Request in PHP
Share on: 
fb share twitter share gplus share more share

Please make a var_export what you got and post here
PHP: var_export - Manual

Pava is offline  
Closed Thread


Bookmarks

Tags
formatting, json, php, request


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 02:34 PM.