I need to grab some json code; it is starting with [
If I try to loop it, I retrieve
Warning: Invalid argument supplied for foreach()
Can someone help me to decode properly this json? thanks
PHP Code:
echo "<h2>Tradedoubler Coupon</h2>";
$tdjson = file_get_contents("http://api.tradedoubler.com/1.0/vouchers.json;voucherTypeId=1?token=280C407EC3D32D2C8E4C04A100DD00FEA9000580");
//$tdobj = json_decode(print_r($tdjson));
$tdobj = json_decode($tdjson,true);
//foreach($tdobj as $prog ) {
echo '<ul>';
echo '<li>' . print_r($tdobj) . '</li>
</ul>';
JSON file:
[
{
id: 20108,
programId: 17269,
programName: "",
code: "6G4KGGDH",
updateDate: "1369813973159",
publishStartDate: "1370037600000",
publishEndDate: "1372629599999",
startDate: "1370037600000",
endDate: "1372629599999",
title: "Sconto",
shortDescription: "kkkkk",
description: "kkkk",
voucherTypeId: 1,
defaultTrackUri: "http://url.com/click?a(1556954)p(17269)ttid(13)",
siteSpecific: false,
discountAmount: 5,
isPercentage: false,
publisherInformation: "",
languageId: "it",
exclusive: false,
currencyId: "EUR",
logoPath: "http://url.com/file/17269/eDreams_100x50.jpg"
},
{
id: 19699,
programId: 29519,
programName: "",
code: "6G4KGGDH",
updateDate: "1369813973159",
publishStartDate: "1370037600000",
publishEndDate: "1372629599999",
startDate: "1370037600000",
endDate: "1372629599999",
title: "Sconto",
shortDescription: "kkkkk",
description: "kkkk",
voucherTypeId: 1,
defaultTrackUri: "http://url.com/click?a(1556954)p(17269)ttid(13)",
siteSpecific: false,
discountAmount: 5,
isPercentage: false,
publisherInformation: "",
languageId: "it",
exclusive: false,
currencyId: "EUR",
logoPath: "http://url.com/file/17269/eDreams_100x50.jpg"
}
]