大家好我已经使用Foursquare API在给定区域创建了一个趋势地点列表:请参阅以下链接http://createmate.co/foursquare-whatshot/
我正在尝试弄清楚如何将每个项目链接到其各自的Foursquare网址。这是迄今为止的代码......
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Foursquare What's Hot</title>
<!-- external CSS link -->
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div id="container">
<h1>Foursquare What's Hot</h1>
<?php
/* GET THE DATA */
$trending_url = file_get_contents("https://api.foursquare.com/v2/venues/trending?ll=40.7,-74&oauth_token=BQEPEMYIFHHH2C1OGBTJDI4GBYV5HQAPNFLR5ON1JIAI42GN&v=20130220");
$trending_output = json_decode($trending_url);
/* TEST THE DATA */
//echo "<pre>";
//print_r($trending_output);
//echo "</pre>";
/* PRINT RESULTS */
for ($i=0;$i<10;$i++) {
echo "<ul id ='locations'>";
echo "<li> <a href= " . $trending_output->response->venues[$i]->canonicalURL . "> <h3>" . $trending_output->response->venues[$i]->name . "<br>";
echo "<li> <h4>" . $trending_output->response->venues[$i]->location->address . "<br>";
echo "</ul>";
}
?>
</div>
</body>
非常感谢任何帮助。
亚当
答案 0 :(得分:0)
您检索的属性应为canonicalUrl
,而不是canonicalURL
。
您还应该在引号中包含href
属性,并且不要忘记关闭<a>
标记。