【发布时间】:2018-02-16 02:11:46
【问题描述】:
我正在尝试从我收到的 API 中检索一些信息。我能够拨打电话并获取所需的信息,但必须进行单独的 HTTP 调用,我相信有更好的方法来做到这一点。
这是我第一次调用时收到的 JSON 字符串的结构。
"data": [{
"1": "1",
"2": 69766,
"3": {
"4": 4
},
"links": {
"1": {
"links": {
"self": "https://localhost/69766/1"
}
},
"2": {
"links": {
"self": "https://localhost/69766/2"
}
}
}],
"links": {
"self": "https://localhost/69766/",
"first": "https://localhost/69766/?page[number]=0",
"next": "https://localhost/69766/?page[number]=1"
}
第一次调用后,我想从自链接中获取一个信息,并转到下一页。
提前致谢。我正在使用 PHP 和 cURL
具体来说,我想从自链接中获取 2,4 和 2。
【问题讨论】:
-
如果 API 返回要访问的 http 端点,您如何设想在不发出另一个 http 请求的情况下访问它们?
标签: php httprequest php-curl