我正在尝试获取网页帖子附件。这是我试图获得的JSON:
{
"attachments": {
"data": [
{
"media": {
"image": {
"height": 720,
"src": "url",
"width": 720
}
}
}
]
},
"id": "post_id"
}
我的@GET
请求:
@GET("{post_id}")
fun getPostsAttachments(@Path("post_id") postId : String?,
@Query("access_token") authToken: String?,
@Query("fields") media : String?)
:Observable<AttachmentsList>
可观察:
var getPostsAttachments: Observable<AttachmentsList> = facebook.getPostsAttachments(postId, "app_token", "attachments")
getPostsAttachments.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribeBy(
onNext = { result ->
imgUrl?.addAll(result.data)
Log.d("TAG_NEXT", "$result")
},
onError = { throwable -> Log.d("TAG_ERROR", throwable.toString()) },
onComplete = { Log.d("TAG_COMPLETE", "$imgUrl") }
)
它返回D/TAG_NEXT: AttachmentsList(data=null)
和D/TAG_COMPLETE: null
。
我该如何解决?也许我的链接请求有误?
答案 0 :(得分:0)
从我在https://developers.facebook.com/docs/graph-api/reference/v2.11/attachment上看到的,你的通话路径是错误的。尝试将Retrofit调用注释更改为@GET("{post_id}/attachments")
。