how to show ''+Ti.Facebook.uid+'/name' as a string

hi guys

how to show a url ==> ''+Ti.Facebook.uid+'/name', as a string (so the username from the person who has logged in with FB)

same idea as showing a picture ==>
var profileView = Ti.UI.createImageView({

1 Answer

  • var label = Ti.UI.createLabel({text: ''+Ti.Facebook.uid+'/name'});
    — answered 3 years ago by Stephen Feather
    • hi stephen,

      i tried this already and it does not show me the users name but rather the url

      — commented 3 years ago by Napp Dev
    • ok, you didn't ask clearly enough.

      Doesn't /name return JSON, so grab the URL with an httpClient call and parse the json to get the data you need.

      — commented 3 years ago by Stephen Feather
      • The FaceBook Graph API is REALLY well documented when compared to other APIs. Before asking how to integrate a 3rd party API with Titanium, please at least try to understand the 3rd party API first. (even if Titanium has built in support, you are still responsible for understanding both ends)

      • returns a binary stream.

      • returns a JSON array. You will need to use Ti.Network.HTTPCLient to grab the JSON array returned from Graph

      Ex: returns:

      "id": "295053353871174",
         "name": "Conversion Center",
         "link": "",
         "namespace": "conversion_center",
         "icon_url": "",
         "logo_url": ""

      — commented 3 years ago by Stephen Feather
    • hi stephen

      with your direction and research on the q&a i have written the following:

      var links = [];

      function retrieveData(callback){
      var httpClient = Titanium.Network.createHTTPClient({
      onload: function() {
      var reply = JSON.parse(this.responseText);
      }});"GET","" + Titanium.Facebook.uid + "/name");

      //if i get a null or undefined response, i'll just take an empty array
      links = returnVar || [];
      //Check there are some links
      if (links.length > 0) {
      //Now i use the links

      as a result i don't see the name of the user, so i don't know where i went wrong

      — commented 3 years ago by Napp Dev