0

我正在尝试为 twitter 构建一个 hastag 提要,我已经阅读了如何创建搜索查询,并且我有这个 json 结构......

{
  "completed_in": 0.026,
  "max_id": 201961894368653313,
  "max_id_str": "201961894368653313",
  "next_page": "?page=2&max_id=201961894368653313&q=wearetwo&lang=en&rpp=100&include_entities=1",
  "page": 1,
  "query": "wearetwo",
  "refresh_url": "?since_id=201961894368653313&q=wearetwo&lang=en&include_entities=1",
  "results": [
    {
{
      "created_at": "Sat, 12 May 2012 01:06:19 +0000",
      "entities": {
        "hashtags": [
          {
            "text": "wearetwo",
            "indices": [
              12,
              21
            ]
          }
        ],
        "urls": [

        ],
        "user_mentions": [
          {
            "screen_name": "crifor",
            "name": "Cristina Forlani",
            "id": 110646291,
            "id_str": "110646291",
            "indices": [
              3,
              10
            ]
          }
        ],
        "media": [
          {
            "id": 201101250740240387,
            "id_str": "201101250740240387",
            "indices": [
              34,
              54
            ],
            "media_url": "http:\/\/p.twimg.com\/Asp0haZCQAMC-Sq.jpg",
            "media_url_https": "https:\/\/p.twimg.com\/Asp0haZCQAMC-Sq.jpg",
            "url": "http:\/\/t.co\/1EXkTMYq",
            "display_url": "pic.twitter.com\/1EXkTMYq",
            "expanded_url": "http:\/\/twitter.com\/crifor\/status\/201101250740240384\/photo\/1",
            "type": "photo",
            "sizes": {
              "small": {
                "w": 340,
                "h": 455,
                "resize": "fit"
              },
              "large": {
                "w": 765,
                "h": 1024,
                "resize": "fit"
              },
              "thumb": {
                "w": 150,
                "h": 150,
                "resize": "crop"
              },
              "orig": {
                "w": 765,
                "h": 1024,
                "resize": "fit"
              },
              "medium": {
                "w": 600,
                "h": 803,
                "resize": "fit"
              }
            }
          }
        ]
      },
      "from_user": "stevoltan",
      "from_user_id": 165713968,
      "from_user_id_str": "165713968",
      "from_user_name": "Stefano Voltan",
      "geo": null,
      "id": 201116057396719616,
      "id_str": "201116057396719616",
      "iso_language_code": "en",
      "metadata": {
        "result_type": "recent"
      },
      "profile_image_url": "http:\/\/a0.twimg.com\/profile_images\/2163464409\/crepes_normal.jpg",
      "profile_image_url_https": "https:\/\/si0.twimg.com\/profile_images\/2163464409\/crepes_normal.jpg",
      "source": "<a href="http:\/\/twitter.com\/#!\/download\/iphone" rel="nofollow">Twitter for iPhone<\/a>",
      "text": "RT @crifor: #wearetwo belle facce http:\/\/t.co\/1EXkTMYq",
      "to_user": null,
      "to_user_id": 0,
      "to_user_id_str": "0",
      "to_user_name": null
    },

我需要提取媒体 url 和文本...有人可以帮帮我吗..我对此很陌生...如果您能给我展示一个可行的示例,我将不胜感激..至少是功能。 ..

4

1 回答 1

0

本文档将向您展示如何将数据转换为可以使用 jQuery 使用的格式:

http://api.jquery.com/jQuery.getJSON/

就像是:

$.getJSON('http://search.twitter.com/search.json?q=wearetwo&lang=en&result_type=recent&rpp=100&include_entities=true', function(data) {
  var media_url = data.results.media.media_url;
  var text = data.text;
});
于 2012-05-14T15:17:52.217 回答