| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 | (function() {
	fs.core.queryFQL = function(fqlQuery, fqlCallback) {
		var fqlURL = "fql?q=" + fqlQuery.replace(/ /g, "+");
		Ti.API.info("https://graph.facebook.com/" + fqlURL);
		Ti.Facebook.requestWithGraphPath(fqlURL, {}, 'GET', fqlCallback);
	};
	
	fs.core.queryAllFriendPostsFQL = function() {
		var query = "SELECT page_id, name, description, page_url, pic_square, fan_count, type, website, general_info ";
		query += "FROM page WHERE page_id ";
		query += "IN (SELECT page_id FROM page_fan WHERE uid ";
		//query += "= " + Ti.Facebook.uid + ")";
		query += "IN (SELECT uid2 FROM friend WHERE uid1 = " + Titanium.Facebook.uid + "))";
		//query += "order by last_name limit 20";
		Ti.Facebook.request('fql.query', {query: query}, fs.core.handleAllFriendPostsFQL);
		// TODO: after calling this fn, display the loading animation
	};
	
	/*
	fs.core.handleFQLResponse = function(callback) {
	};
	*/
	
	fs.core.handleAllFriendPostsFQL = function(result) {
		if (result.success) {
			var postsList = JSON.parse(result.result);
			/*			
			Ti.API.info(postsList.length);
			Ti.API.info(postsList[0].name);
			Ti.API.info(postsList[0].page_id);
			Ti.API.info(postsList[0].website);
			*/
			Ti.API.fireEvent("processPosts", {list:postsList});
		} else if (result.error) {
			//Ti.API.info("ERROR: " + result.error); // TODO: remove
			Ti.API.fireEvent("processFQLError", {what:result.error});
		} else {
			//Ti.API.info("ERROR: unknown response from FQL query"); // TODO: remove
			Ti.API.fireEvent("processFQLError", {what:"unknown FQL response"});
		}
	}; // TODO: handle timeouts
	
})();
 |