我正在尝试为VK社交网络编写音乐浏览器应用程序,我在为其服务调用API时遇到了一些麻烦。
基本上,他们为开发者网站上的某个查询提供的示例JSON响应与我的应用和浏览器在直接插入查询URL时读取的内容有很大不同。
我认为问题在于网站上的示例查询比实际返回的查询更容易实现,所以我有点希望我错过了一些明显的东西以便我不要我必须学会自己挑选JSON响应并将其链接到类(而不是使用json2csharp)
我会给大家一个关于我所看到的差异的例子。首先是开发人员站点提供的示例响应:
response: {
count: 3411,
items: [{
id: 18819,
from_id: -41750294,
owner_id: -41750294,
date: 1446984665,
post_type: 'post',
text: 'Various Artists – Resonance / Turncoat
Label: Quarantine Recordings
Catalogue: QRN 2004
Country: U.K.
Release Date: 30 Oct 2015',
attachments: [{
type: 'photo',
photo: {
id: 386477538,
album_id: 212496672,
owner_id: 1881108,
photo_75: 'https://pp.vk.me/...27b/0be4siJV0lY.jpg',
photo_130: 'https://pp.vk.me/...27c/aE3TNi1R2JA.jpg',
photo_604: 'https://pp.vk.me/...27d/4LQ27MVxPX8.jpg',
photo_807: 'https://pp.vk.me/...27e/Z8tJgN8Z3gU.jpg',
photo_1280: 'https://pp.vk.me/...27f/q2HYIQLwxHI.jpg',
width: 1024,
height: 1024,
text: 'QRN2004',
date: 1446984456,
access_key: 'c962ab59cb3915bdf2'
}
}, {
type: 'audio',
audio: {
id: 410724007,
owner_id: 2000374498,
artist: 'Fierce & Dom',
title: 'Resonance',
duration: 322,
date: 1446984665,
url: 'https://psv4.vk.m...CpMuxnT_0RUvJqxxIoZ',
genre_id: 8
}
}, {
type: 'audio',
audio: {
id: 412128187,
owner_id: 2000374305,
artist: 'Fierce & Zero T',
title: 'Turncoat',
duration: 331,
date: 1446984665,
url: 'https://psv4.vk.m...BcWuQ9T3uFA0_MKyuAk',
genre_id: 8
}
}],
post_source: {
type: 'vk'
},
comments: {
count: 1,
can_post: 1
},
likes: {
count: 47,
user_likes: 0,
can_like: 1,
can_publish: 1
},
reposts: {
count: 11,
user_reposted: 0
}
}],
profiles: [],
groups: [{
id: 41750294,
name: 'Neurodeep Community',
screen_name: 'neurodeep_community',
is_closed: 0,
type: 'page',
is_admin: 0,
is_member: 1,
photo_50: 'https://pp.vk.me/...f3d/9tc7nU8eRws.jpg',
photo_100: 'https://pp.vk.me/...f3c/rqliVAMWVNI.jpg',
photo_200: 'https://pp.vk.me/...f3b/Ll62Rn6xmok.jpg'
}]
}
现在手动插入网址(https://api.vk.com/method/wall.get?owner_id=-41750294&offset=1&count=1&filter=owner&extended=1)
的响应{"response":{"wall":[3412,{"id":18819,"from_id":-41750294,"to_id":-41750294,"date":1446984665,"post_type":"post","text":"Various Artists – Resonance \/ Turncoat<br>Label: Quarantine Recordings<br>Catalogue: QRN 2004 <br>Country: U.K.<br>Release Date: 30 Oct 2015","attachment":{"type":"photo","photo":{"pid":386477538,"aid":212496672,"owner_id":1881108,"src":"http:\/\/cs627217.vk.me\/v627217108\/1d27c\/aE3TNi1R2JA.jpg","src_big":"http:\/\/cs627217.vk.me\/v627217108\/1d27d\/4LQ27MVxPX8.jpg","src_small":"http:\/\/cs627217.vk.me\/v627217108\/1d27b\/0be4siJV0lY.jpg","src_xbig":"http:\/\/cs627217.vk.me\/v627217108\/1d27e\/Z8tJgN8Z3gU.jpg","src_xxbig":"http:\/\/cs627217.vk.me\/v627217108\/1d27f\/q2HYIQLwxHI.jpg","width":1024,"height":1024,"text":"QRN2004","created":1446984456,"access_key":"02aab51e5ff130f264"}},"attachments":[{"type":"photo","photo":{"pid":386477538,"aid":212496672,"owner_id":1881108,"src":"http:\/\/cs627217.vk.me\/v627217108\/1d27c\/aE3TNi1R2JA.jpg","src_big":"http:\/\/cs627217.vk.me\/v627217108\/1d27d\/4LQ27MVxPX8.jpg","src_small":"http:\/\/cs627217.vk.me\/v627217108\/1d27b\/0be4siJV0lY.jpg","src_xbig":"http:\/\/cs627217.vk.me\/v627217108\/1d27e\/Z8tJgN8Z3gU.jpg","src_xxbig":"http:\/\/cs627217.vk.me\/v627217108\/1d27f\/q2HYIQLwxHI.jpg","width":1024,"height":1024,"text":"QRN2004","created":1446984456,"access_key":"02aab51e5ff130f264"}},{"type":"audio","audio":{"aid":410724007,"owner_id":2000374498,"artist":"Fierce & Dom","title":"Resonance","duration":322,"url":"http:\/\/cs422118.vk.me\/u1881108\/audios\/015b54d160bf.mp3?extra=pwpTdyJOeDJRbnsCJg6aAs4CS0AcoLKR_2--skxAdGqvgP7umh36xc9hbsNQK8OuGX00cDCbiCpMvx2C808Cu8vjwNFN","performer":"Fierce & Dom","genre":8}},{"type":"audio","audio":{"aid":412128187,"owner_id":2000374305,"artist":"Fierce & Zero T","title":"Turncoat","duration":331,"url":"http:\/\/cs422118.vk.me\/u1881108\/audios\/56c37e9c4bac.mp3?extra=AsszsN2Qvcmr5Udr3TKzyDQoDvs1wSnI1bOj1pmcrYkDj0c4McuQF3zaEB3SiX_Tk6gAUtJTTBcW6gFT3rMQj_8JnOJw","performer":"Fierce & Zero T","genre":8}}],"comments":{"count":1},"likes":{"count":48},"reposts":{"count":11}}],"profiles":[],"groups":[{"gid":41750294,"name":"Neurodeep Community","screen_name":"neurodeep_community","is_closed":0,"type":"page","photo":"http:\/\/cs627227.vk.me\/v627227108\/10f3d\/9tc7nU8eRws.jpg","photo_medium":"http:\/\/cs627227.vk.me\/v627227108\/10f3c\/rqliVAMWVNI.jpg","photo_big":"http:\/\/cs627227.vk.me\/v627227108\/10f3b\/Ll62Rn6xmok.jpg"}]}}
如果我愚蠢并且遗失了某些内容,或者即使我因为初学者身份而咀嚼太多让我咀嚼,也可以随时告诉我,任何帮助都表示赞赏:)
答案 0 :(得分:0)
经过多次试验和错误,有效的方法是从返回的字符串中以编程方式删除“{”响应“:”。我没有技巧告诉你为什么,但这似乎是它被挂起的东西!
答案 1 :(得分:0)