如何使用php_decode和url在php中获取json对象结果

时间:2014-02-15 16:04:39

标签: php json

下面是我的json对象结果google api现在我想从它获取封面的url,这是json对象中的参数'thumbnail',但我不知道我怎么能回复它可以有人在这帮助我吗? / p>

{
         "kind": "books#volumes",
         "totalItems": 1,
         "items": [
          {
           "kind": "books#volume",
           "id": "9VKCkifBlisC",
           "etag": "hhhZjjV6arI",
           "selfLink": "url",
           "volumeInfo": {
            "title": "Instructor's manual to accompany An introduction",
            "authors": [
             "Jean-Paul Tremblay",
             "P. G. Sorenson"
            ],
            "publishedDate": "1976",
            "industryIdentifiers": [
             {
              "type": "ISBN_10",
              "identifier": "0070651515"
             },
             {
              "type": "ISBN_13",
              "identifier": "9780070651517"
             }
            ],
            "pageCount": 278,
            "printType": "BOOK",
            "categories": [
             "Computers"
            ],
            "averageRating": 5.0,
            "ratingsCount": 1,
            "contentVersion": "0.0.1.0.preview.0",
            "imageLinks": {
             "smallThumbnail": "url",
            /*this is what i need*/ 
                       "thumbnail": "url"
            },
            "language": "en",
            "previewLink": "url",
            "infoLink": "url",
            "canonicalVolumeLink": "url"
           },
           "saleInfo": {
            "country": "IN",
            "saleability": "NOT_FOR_SALE",
            "isEbook": false
           },
           "accessInfo": {
            "country": "IN",
            "viewability": "NO_PAGES",
            "embeddable": false,
            "publicDomain": false,
            "textToSpeechPermission": "ALLOWED",
            "epub": {
             "isAvailable": false
            },
            "pdf": {
             "isAvailable": false
            },
            "webReaderLink": "url",
            "accessViewStatus": "NONE",
            "quoteSharingAllowed": false
           }
          }
         ]
        }

1 个答案:

答案 0 :(得分:0)

你可以这样做..

$arr = json_decode($json,true);
echo $arr['items'][0]['volumeInfo']['imageLinks']['thumbnail'];

Demo