我有一个json文件,我想从数组中提取几行来构建事件列表。使用curl抓住json。
我可以获取文件的转储但不知道如何从数组中隔离特定字段。
数据看起来像这样,我想提取名称,网址和广告。 IsPublic
{
"Forms":[
{
"Name":"BRIO Tuscan Grille",
"Description":"Event descripton here\n\nHosts: Dave ",
"RedirectMessage":"Great! Thanks for filling out my form!",
"Url":"brio-tuscan-grille",
"Email":"email@email.com",
"IsPublic":"1",
"Language":"english",
"StartDate":"2000-01-01 12:00:00",
"EndDate":"2030-01-01 12:00:00",
"EntryLimit":"9",
"DateCreated":"2013-09-30 09:00:09",
"DateUpdated":"2014-02-10 06:35:41",
"Hash":"123456",
"LinkFields":"https:\/\/mysite.com\/api\/v3\/forms\/123456\/fields.json",
"LinkEntries":"https:\/\/mysite.com\/api\/v3\/forms\/123456\/entries.json",
"LinkEntriesCount":"https:\/\/mysite.com\/api\/v3\/forms\/123456\/entries\/count.json"
},
//This is the requesting page
<?php
$curl = curl_init('$url');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERPWD, 'AUTHCODEHERE:footastic');
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'Forms XML');
$response = curl_exec($curl);
$resultStatus = curl_getinfo($curl);
if($resultStatus['http_code'] == 200) {
echo htmlentities($response);
} else {
echo 'Call Failed '.print_r($resultStatus);
}
?>