I write a qml program to retrieve the photos album from flickr website, using the following js code, it works fine.
function flickrGetPhotoSets()
{
req = new XMLHttpRequest();
req.onreadystatechange = flickrGetPhotoSetsResponse;//parseFunc
var url = "http://api.flickr.com/services/rest/?method=flickr.photosets.getList&api_key=apikey &user_id=userid&format=json"
req.open("POST", url, true);
// req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
req.setRequestHeader("Content-Encoding", "UTF-8");
req.send();
}
function flickrGetPhotoSetsResponse()
{
console.log("taobao response start...");
if (req.readyState == XMLHttpRequest.HEADERS_RECEIVED)
{
}
else if (req.readyState == XMLHttpRequest.DONE)
{
if(req.responseText.length == 0 || req.responseText == null)
{
return;
}
console.log( req.responseText);
var rsp= req.responseText.toString();
var start = rsp.indexOf("(") + 1;
console.log("string start:"+start);
var end = rsp.length - 1;
var jSONString = rsp.substring( start, end);
console.log(jSONString);
photosetJson = JSON.parse(jSONString);
background.formatAlbumListModel();
}
}
Then I try to retrieve photo albums from another website, using the similar js code as following code , it runs fine as picture 2 when I using Qt Creator to compile
function taotaoGetAccessToken()
{
req = new XMLHttpRequest();
req.onreadystatechange = renrenGetAccessTokenResponse;//parseFunc
var url = "https://graph.taotao.com/oauth/token?grant_type=password&username=username&passwo rd=password&client_id=clientid &client_secret=clientsecret&scope=read_user_alb um read_user_photo"
req.open("POST", url, true);
// req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
req.setRequestHeader("Content-Encoding", "UTF-8");
req.send();
}
function taotaoGetAccessTokenResponse()
{
console.log("taotao response start...");
if (req.readyState == XMLHttpRequest.HEADERS_RECEIVED)
{
}
else if (req.readyState == XMLHttpRequest.DONE)
{
if(req.responseText.length == 0 || req.responseText == null)
{
return;
}
console.log( req.responseText);
var rsp= req.responseText.toString();
var accesstokenJson= JSON.parse(rsp);
accesstoken= accesstokenJson["access_token"]
var paraArray =
[
"api_key=" + "apikey"
,"method="+ "photos.getAlbums"
,"access_token=" + accesstoken
,"format=" + "JSON"
,"v=" + "1.0"
,"uid=" + "224243671" //"243571487"
];
//
paraArray.sort();
var signString= paraArray.join("");
signString= signString+ "signstring"
console.log( signString);
var sign= hex_md5(signString);
paraArray.push("sig="+sign)
taotaoGetAlbumsApiURL= "http://api.taotao.com/restserver.do?"+paraArray.join("&");
console.log("API URL:"+ taotaoGetAlbumsApiURL);
taotaoGetPhotoSets(taotaoGetAlbumsApiURL)
}
}
function taotaoGetPhotoSets(apirul)
{
req = new XMLHttpRequest();
req.onreadystatechange = taotaoGetPhotoSetsResponse;//parseFunc
var url = apirul
req.open("POST", url, true);
// req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
req.setRequestHeader("Content-Encoding", "UTF-8");
req.send();
}
function taotaoGetPhotoSetsResponse()
{
console.log("taotao response start...");
if (req.readyState == XMLHttpRequest.HEADERS_RECEIVED)
{
}
else if (req.readyState == XMLHttpRequest.DONE)
{
if(req.responseText.length == 0 || req.responseText == null)
{
return;
}
console.log( req.responseText);
var rsp= req.responseText.toString();
photosetJson= JSON.parse(rsp);
// if (photosetJson["error_code"]==undefined)
background.formatTaotaoAlbumListModel();
// else
// {
// taotaoGetPhotoSets(taotaoGetAlbumsApiURL);
// console.log("get photoset return error code");
// }
}
}
However, when I deploy the second program, it is not working as in Qt Creator. It displays as pictures 3, in the release folder, besides the compiled exe file, I do include libgcc_s_dw2-1.dll, mingwm10.dll, imageformats, and qt related dlls, the first application can be deployed successfully when I including these files. This is really a weird problem, what is the problem of the second part js code for deployment, why the second part js code can run successfully in Qt creator but fails in deployment? Ps: the two parts js code both linked to the same qml.
Bookmarks