Hi,
Please provide me a solution of add a friends from facebook this code is working fine previously but later there shows a error like can not set app id of undefined. i replace the android facebook code to ios titanium code but the login from facebook is done successfully but there shows a error like cannot call method requestwithGraphPath of undefined. so please provide me a solution. i am sending my both code.
fb.addEventListener('login', function(e) { if (e.success) { var accToken = fb.getAccessToken(); // var accToken = Titanium.Facebook.getAccessToken(); //alert(accToken); var fb_win = Ti.UI.createWindow({ navBarHidden:true, url:'getFacebookfriends.js', navBarHidden: true, backgroundColor:'white' }); fb_win.open({fullscreen:true});
} else if (e.error) { alert(e.error); } else if (e.cancelled) { alert("Canceled"); } });
and for addition of friends i write this code .this will run properly but right it have problem of requestwithgraphpath.please help me to resolve this problem.
fb_win.addEventListener('open', getFacebookFriendList); //------------------function getFacebookFriendList get user's facebook friends---------------// var fb_win_headerView =Ti.UI.createView({ backgroundImage:'images/header_bg.png', width:'100%', height:'10%', top:'0%', title:'faq_wins', textAlign: 'centre', color:'#fff' });
var fb_win_back_button_header =Ti.UI.createButton({ width:21, height:17, left:'3%', backgroundImage:'images/back_arrow_image.png', }); var fb_win_headerlabel = Ti.UI.createLabel({ color: '#fff', text: 'Facebook', textAlign: 'center', font: { fontSize: 16, fontWeight: 'bold', fontFamily:'ThisApp.FONTBOLD', }, }); fb_win_headerView.add(fb_win_back_button_header); fb_win_headerView.add(fb_win_headerlabel); fb_win.add(fb_win_headerView);
//==================click on back button=-------------------// fb_win_back_button_header.addEventListener('touchstart',function(e){ Titanium.UI.currentWindow.close(); });
var tableview = Ti.UI.createTableView({ data:[], top:'12%', separatorColor:'transparent' });
tableview.addEventListener("click", function(e){ if(e.source.clickName =="invite"){
sendFacebookNotification(e.source.fbid);
} }); function getFacebookFriendList(){ var searchData =[ ]; // Ti.Facebook.requestWithGraphPath('me/friends', {}, 'GET', function(e) { Titanium.Facebook.requestWithGraphPath('me/friends?fields=id,name,picture&&limit=30', {}, 'GET', function(e) { alert('sdfkgsgkhsgsgkgssfh');
if (e.success) {
var resObj =JSON.parse(e.result);
var frdata =resObj.data;
var len =frdata.length;
for(j=0;j<len;j++){
var thisRow = Ti.UI.createTableViewRow();
var invitefriend_dynamicview = Titanium.UI.createView({
top:0,
backgroundColor:'white',
width:'auto',
height:75
});
var invitefriend_user_imageview = Ti.UI.createImageView({
image:'http://graph.facebook.com/' + frdata[j].id + '/picture',
width:75,
height:75,
left:2,
top:2,
bottom:2
});
invitefriend_dynamicview.add(invitefriend_user_imageview);
var invitefriend_user_name = Ti.UI.createLabel({
color: '#000',
font: {
fontSize:16,
fontWeight: 'bold',
fontFamily:'ThisApp.FONTBOLD',
},
text: frdata[j].name,
left:'25%',
top:2,
width: '50%',
height: 'auto',
backgroundImage:'none'
});
invitefriend_dynamicview.add(invitefriend_user_name);
var invite_friend_done_btn = Ti.UI.createButton({
backgroundImage:'images/add_button_image.png',
width:32,
height:32,
right:'5%',
fbid:frdata[j].id,
clickName:'invite'
});
invitefriend_dynamicview.add(invite_friend_done_btn);
thisRow.add(invitefriend_dynamicview);
searchData.push(thisRow);
}
tableview.setData(searchData);
fb_win.add(tableview);
//actInd.hide();
//===============add close button=================//
} else if (e.error) {
alert(e.error);
} else {
alert('Unknown response');
}
});
}
//POST /{recipient_userid}/notifications?access_token= … &template= … &href= " + function sendFacebookNotification(recipient_userid){ var accToken = Titanium.Facebook.getAccessToken(); //alert(accToken); var params ={message : 'Create App Using AppHome', link:'http://www.app-home.jp/AppHome/', picture:'http://www.app-home.jp/AppHome/img/mobile.png', name:'AppHome', caption:'AppHome Mobile Engine',description:'The fastest and smartest way to create and manage your mobile applications Easy to use, convenient, cross platform, available in Cloud...'}; Titanium.Facebook.requestWithGraphPath('me/feed', params, "POST", function(e) { if (e.success) { alert("Success! From FB: " + e.result); } else { if (e.error) { alert(e.error); } else { alert("Unkown result"); } } });
}