0

嗨,我已经使用 Foursquare API 创建了给定区域中的热门地点列表:请参阅以下链接http://createmate.co/foursquare-whatshot/

我试图弄清楚如何使每个项目链接到其各自的 Foursquare URL。这是到目前为止的代码......

<!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>

任何帮助深表感谢。

亚当

4

1 回答 1

0

您检索的属性应该是canonicalUrl,而不是canonicalURL

您还应该href用引号将您的属性括起来,并且不要忘记关闭您的<a>标签。

于 2013-02-27T20:42:19.350 回答