PDA

View Full Version : Facebook API Integration



BigBMan
08-30-2011, 07:17 AM
I've gotten as far as logging in and posting to Facebook with the following implementation:

* MyAppDelegate - implementation of FBAPI calls and callbacks
** onOSMessage - I have defined outgoing messages like MESSAGE_FACEBOOK_LOGIN and MESSAGE_FACEBOOK_POST_STREAM
* BaseApp::OnMessage - calls signals from custom GUI messages, (called from MyAppDelegate callbacks) like MESSAGE_TYPE_FACEBOOK_LOGIN_OK and MESSAGE_TYPE_FACEBOOK_DIALOG_FINISHED

Feels kind of messy, but it seems the best way to do Facebook integration in a cross platform way. Wondering what your thoughts are on this.

Also, I'm looking to get more complex data, like arrays of friends and their information, but there isn't a variant type that supports that complex objects or arrays of variants.

Thoughts? Thanks!!!

Seth
08-31-2011, 03:14 AM
Hmm, I see the problem.

In the past I've sort of been winging it by constantly adding new functions .. but I agree, we need a less messy way to send data from a native system (ObjectC or Java in the case of Android) to Proton's stuff.

Using OSMessage to send a mem pointer and size (could do some fancy (ie, ugly) casting, or add new members) should work for iOS but I don't think that would work for Android due to the JNI stuff that happens between them.

Like, if you look at GetRegionString in AndroidUtils.cpp, you see the hoops that have to be jumped through to send a simple string with Android...

Hmm, maybe I need an OnGetData(C_USER_TYPE+1, pDataPointer, size); type thing that gets called, and each platform (in AndroidUtils.cpp, iOSUtils.cpp etc) can figure out how to do the actual transfer and then call that.

To send more complex data like tables/structures should probably be avoided if possible, but pure data should give you everything you need, just a hassle to pack/unpack sometimes.

BigBMan
08-31-2011, 08:03 AM
Eeek! Wish I could help at that level, but I'm not versed enough with Android yet :)

I did get some basic Facebook functions working though. I've got login, getting friends and posting to a wall working using Os Messages. For getting friends, just send a mGUI Message for every friend retrieved. I had to add the following to MessageManager.cpp because I wanted to use the VariantList as a parameter:



//
// Custom for sending a VariantList
//
void MessageManager::SendGUI( eMessageType type, VariantList* v, int deliverTimeMS, eTimingSystem timing )
{
Message *m = new Message(MESSAGE_CLASS_GUI, timing, type);
m->SetDeliveryTime(deliverTimeMS);
m->Set(v);

Send(m);
}


Will try to send an example app soon.

Next, figuring out how to load user images. That's probably where we'll probably have to get into the good stuff :S