This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How to make a HTTP request with HTTP header in QTScript.

Tags: None
(comma "," separated)
User avatar
metalbrick
Registered Member
Posts
23
Karma
0
OS
I am trying to write a simple script in Amarok for listening streaming music on some websites,

some JSONs need authorization token in HTTP header to get,
and I found that is impossible to do that with the "Downloader" API: https://community.kde.org/Amarok/Development/Script_API#Downloader

then I tried the QT binding with QHttp, as follows
Code: Select all
Importer.loadQtBinding("qt.core");
Importer.loadQtBinding("qt.network");

url = new QUrl("https://api.douban.com/v2/fm/hot_channels");
req = new QHttp("api.douban.com");
req.requestFinished.connect(req, on_requestFinished);
req.get(url);

function on_requestFinished(id, error) {
    var result = req.readAll();
    Amarok.alert(req.errorString());
}

but the response was empty, while the equivalent code in NATIVE QT worked just fine.
Where did I go wrong ? Anyone can help ?


Or is there a comprehensive manual about Writing a plugin of Amarokin C++ ?


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]