NimbleKit - fast iOS app development

FaceBook Connect

Forum for posting sample code and examples, new posts creation is not allowed, but everybody can comment

Re: FaceBook Connect

Postby tarnfeld » Sun Jan 17, 2010 12:32 am

Can you pre-fill the text to post to your wall, might integrate Share with Facebook with Snippety ;)
tarnfeld
 
Posts: 189
Joined: Mon Jun 15, 2009 9:37 pm

Re: FaceBook Connect

Postby sunny » Sun Jan 17, 2010 2:02 am

yeah, everything in a message can be changed/added from the code, download the project and write something on my wall.
I understand that some of your friends can be offended that you test your app on their walls in facebook, but feel free to test it on mine :)
User avatar
sunny
Staff
 
Posts: 2666
Joined: Sat May 30, 2009 5:18 am
Location: Palo Alto, California

Re: FaceBook Connect

Postby eras3r » Sun Jan 17, 2010 6:26 pm

What should I modify in order to write only on my wall a sentence coming from a variable?

Thanks
Eras3r
User avatar
eras3r
 
Posts: 169
Joined: Fri Nov 20, 2009 10:53 pm

Re: FaceBook Connect

Postby lmarcogimenez » Mon Jan 18, 2010 8:28 pm

Hi Sunny:

Do you know why when I get the friend list, the spanish characters like "ñ", "é", "ó", and so on, don't appear properly?
Attachments
fb.png
Friend list
fb.png (21.36 KiB) Viewed 1316 times
lmarcogimenez
 
Posts: 112
Joined: Mon Oct 19, 2009 8:33 pm

Re: FaceBook Connect

Postby sunny » Mon Jan 18, 2010 8:30 pm

did you specify <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> in <head> section?
User avatar
sunny
Staff
 
Posts: 2666
Joined: Sat May 30, 2009 5:18 am
Location: Palo Alto, California

Re: FaceBook Connect

Postby lmarcogimenez » Mon Jan 18, 2010 8:34 pm

Yes, I've tried with utf-8 and iso-8859-1, both of them with the same result.
lmarcogimenez
 
Posts: 112
Joined: Mon Oct 19, 2009 8:33 pm

Re: FaceBook Connect

Postby sunny » Mon Jan 18, 2010 9:19 pm

found what is the problem, it's JSON encoder does not encode unicode symbols properly :-\
will fix that in next release, for now you can pass the strings from obj-c (will be even better then whole array as the list of friends will fill one by one rather then wait for long time and get whole list)
here how it can be, replace 'else if' block with this code on 169 line of code:
Code: Select all
      else if ([request.userInfo isEqualToString:@"friend_name_request"])
      {
         NSDictionary* person = [result objectAtIndex:0];
         [self._webView performSelectorOnMainThread:@selector(stringByEvaluatingJavaScriptFromString:) withObject:[NSString stringWithFormat:@"newFriendAdded('%@', '%@')", [person objectForKey:@"name"], [person objectForKey:@"uid"]] waitUntilDone:NO];
      }


and remove this on 50 line of code
Code: Select all
while (_requestInProgress) {
      [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.5]]; // wait for request to complete or fail
   }


and remove on 46 line
Code: Select all
_requestInProgress = YES;


also you will need to modify main.html file to obtain not array but having callback function newFriendAdded(name, uid) and remove &sync=yes from CallNKitAction("getFriendsList?className=AppFBController");
I attach working example here
Attachments
Archive.zip
(88.71 KiB) Downloaded 161 times
User avatar
sunny
Staff
 
Posts: 2666
Joined: Sat May 30, 2009 5:18 am
Location: Palo Alto, California

Re: FaceBook Connect

Postby lmarcogimenez » Mon Jan 18, 2010 11:12 pm

Great Sunny!

Progressive friend list loading is better to avoid long time delay, but I would like to put in the page an activityIndicator to inform the user that some friends are not loaded yet. Is it possible to know when the list is completed?
lmarcogimenez
 
Posts: 112
Joined: Mon Oct 19, 2009 8:33 pm

Re: FaceBook Connect

Postby sunny » Tue Jan 19, 2010 3:48 am

yep, else if section on line 167 should be:
Code: Select all
      else if ([request.userInfo isEqualToString:@"friend_name_request"])
      {
         NSDictionary* person = [result objectAtIndex:0];
         [self._webView performSelectorOnMainThread:@selector(stringByEvaluatingJavaScriptFromString:) withObject:[NSString stringWithFormat:@"newFriendAdded('%@', '%@')", [person objectForKey:@"name"], [person objectForKey:@"uid"]] waitUntilDone:NO];
         if (--_uidsCount == 0)
         {
            // here it is loaded, we can call function to stop indicator
            [self._webView performSelectorOnMainThread:@selector(stringByEvaluatingJavaScriptFromString:) withObject:@"stopFriendsLoadingIndicator()" waitUntilDone:NO];
         }
      }         
User avatar
sunny
Staff
 
Posts: 2666
Joined: Sat May 30, 2009 5:18 am
Location: Palo Alto, California

Re: FaceBook Connect

Postby lmarcogimenez » Tue Jan 19, 2010 8:14 am

Works!!!

Thank you.
lmarcogimenez
 
Posts: 112
Joined: Mon Oct 19, 2009 8:33 pm

PreviousNext

Return to Sample Code

Who is online

Users browsing this forum: No registered users and 0 guests