Application type: Mobile Titanium SDK: Google APIs Android 2.2 Platform & version: Android 4.1 Device: Android Emulator Host OS: Ubuntu 12.04 Titanium Studio: 2.1.2
I want to create an app that logs into your account in a certain web page, specified in the code, and then I want to do math operations with the numerical values that are given in the account. The thing is that I don't know how to access the variables used in my account's web page to do the math operations, and I can't do the login either. Can someone please help me? Thanks in advance!
2 Answers
I'm getting an illegal operation error or something like that This is the code I currently have:
var httpRequest = function(params) { var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function() {
if(params.hasOwnProperty('callback')) {
if(typeof params.callback == 'function') {
params.callback(this.responseText);
}else {
Ti.API.error('getXML: Invalid callback function');
}
}
};
xhr.onerror = function() {
Ti.API.error(this.status + ' - ' + this.statusText);
};
xhr.open( params.hasOwnProperty('method') ? params.method : 'GET', params.url);
try {
if(params.hasOwnProperty('username') && params.hasOwnProperty('password')) {
authstr = 'Basic ' +Titanium.Utils.base64encode(params.username+':'+params.password);
xhr.setRequestHeader('Authorization', authstr);
}
}catch(e) {
Ti.API.error('Error in getXML: ' + e.message);
}
xhr.send();
};
//Call it like this httpRequest( { url: ‘https://www.4life.com/login/default.aspx’, username: ‘username’, password: ‘password’, xmlParam: ‘myxmlcontent’, callback: function(resp) { //All } });
This code works with Facebook, but I want to use with https://www.4life.com/login/default.aspx, how can I do this? Thanks in advance!
var Cloud = require('ti.cloud'); Titanium.Facebook.appid = "285243484913611";//Production Titanium.Facebook.permissions = ['publish_stream', 'read_stream'];
var win = Ti.UI.createWindow({ title : "ACS Social Integrations" });
var fbSignupBtn = Ti.UI.createButton({ title : "Login with Facebook", width : 160, top : 50 }); win.add(fbSignupBtn);
fbSignupBtn.addEventListener('click', function() { if (!Titanium.Facebook.loggedIn) { Titanium.Facebook.authorize(); } });
//add SocialIntegrations in Facebook login event listener Titanium.Facebook.addEventListener('login', function(e) { if (e.success) { alert("login Success "); //code for SocialIntegrations } else if (e.error) { alert("Error = " + e.error); } else if (e.cancelled) { alert("Canceld"); } });
win.open();
Your Answer
Think you can help? Login to answer this question!