在你的榜樣,ids
來發送的身體在POST請求的一部分,但API希望它是在查詢和請求是GET。
嘗試下面的curl命令:
curl -u "{username}":"{password}" "https://gateway.watsonplatform.net/concept-insights/api/v2/corpora/public/ibmresearcher/conceptual_search?ids=%5B%22%2Fgraphs%2Fwikipedia%2Fen-20120601%2Fconcepts%2FArtificial_intelligence%22%2C%20%22%2Fgraphs%2Fwikipedia%2Fen-20120601%2Fconcepts%HTML%22%5D&cursor=0&limit=10"
它會做使用兩個概念人工智能和HTML的概念搜索。
輸出:
{
"query_concepts": [{
"id": "/graphs/wikipedia/en-20120601/concepts/Artificial_intelligence",
"label": "Artificial intelligence"
}, {
"id": "/graphs/wikipedia/en-20120601/concepts/Machine_learning",
"label": "Machine learning"
}],
"results": [{
"explanation_tags": [{
"concept": {
"id": "/graphs/wikipedia/en-20120601/concepts/Machine_Learning",
"label": "Machine Learning"
},
"score": 0.99816346,
"parts_index": 0,
"text_index": [
1024,
1089
]
}, {
"concept": {
"id": "/graphs/wikipedia/en-20120601/concepts/Machine_Intelligence",
"label": "Machine Intelligence"
},
"score": 0.9945005,
"parts_index": 0,
"text_index": [
2097,
2117
]
}, {
"concept": {
"id": "/graphs/wikipedia/en-20120601/concepts/Artificial_intelligences",
"label": "Artificial intelligences"
},
"score": 0.9945005,
"parts_index": 0,
"text_index": [
2557,
2580
]
}, {
"concept": {
"id": "/graphs/wikipedia/en-20120601/concepts/International_Conference_on_Machine_Learning",
"label": "International Conference on Machine Learning"
},
"score": 0.9817866,
"parts_index": 0,
"text_index": [
2658,
2712
]
}, {
"concept": {
"id": "/graphs/wikipedia/en-20120601/concepts/ICML",
"label": "ICML"
},
"score": 0.9817866,
"parts_index": 0,
"text_index": [
2714,
2718
]
}, {
"concept": {
"id": "/graphs/wikipedia/en-20120601/concepts/Feature_selection",
"label": "Feature selection"
},
"score": 0.97459584,
"parts_index": 1,
"text_index": [
1521,
1538
]
}],
"id": "/corpora/public/ibmresearcher/documents/il-NOAMS",
"label": "Slonim, Noam",
"score": 0.99739265
}]
}
你需要URL編碼JSON數組所以下面的概念:
["/graphs/wikipedia/en-20120601/concepts/Artificial_intelligence", "/graphs/wikipedia/en-20120601/concepts/Machine_learning"]
使用在線URL編碼器一樣http://meyerweb.com/eric/tools/dencoder/
%5B%22%2Fgraphs%2Fwikipedia%2Fen-20120601%2Fconcepts%2FArtificial_intelligence%22%2C%20%22%2Fgraphs%2Fwikipedia%2Fen-20120601%2Fconcepts%HTML%22%5D
最後使用ids=<encoded array>
作爲URL的一部分。
這個伎倆! – blacknred0