Playmaker Forum

PlayMaker News => General Discussion => Topic started by: escpodgames on August 02, 2013, 07:31:23 PM

Title: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: escpodgames on August 02, 2013, 07:31:23 PM
Hi,

So I thought I'd create a thread for the creation of these actions (I'm currently making). Would be great to get an idea of what everyone who would potentially use these action would need.
*Red Can not be created*
*OrangeNot created yet*
*Blue Have been created but not tested*
*Green Have been tested and work*

FACEBOOK
Setup actions
Log-in
Initialize Facebook
Get Session Permissions
Session Validation
Get Access Token
Renew Credentials For All Facebook Accounts
Log-out
Messaging actions
Can User Use Facebook Composer
Message Composer  - Used to post a short message
Image Composer - used to post an image with a small caption
Show Publish Dialog Posts an image(optional) message (optional) Link(optional)

User actions
Get User profile picture
Get Users ID
Get Users Name
Friends actions
Get Friend list - (will use array maker)
Get Friends profile pictures (will use array maker)
Get Friends with app installed (will use array maker)
Viral actions
Like - from what ive seen this not possible to do within an app so have created a separate action called LikePage which just opens a facebook URL
LikePage
Invite friends

TWITTER
Setup actions
Is Logged In
Log-in
init
Viral actions
Tweet
TweetComplete

GAMECENTER
Setup actions
Is Available
Get Player Alias
Get Player ID
Get Scores
Leader-boards
Submit score
Achievements
Init Achievements
Get Achievements
Report Achievements
Show Achievement Banner




Here is a great facebook/prime[31] setup tutorial video
Title: Re: IOS Facebook/Twitter Prime[31] Actions
Post by: escpodgames on August 02, 2013, 09:55:38 PM
Just found someone (cant contact them) requesting these actions as a job on elance .... so if that's you I'd be keen to throw some money in the pot otherwise ill keep plugging along ... not sure how much I can do.

https://www.elance.com/j/playmaker-actions-prime-social-networking-plugin/44940500/
Title: Re: IOS Facebook/Twitter Prime[31] Actions
Post by: escpodgames on August 03, 2013, 08:29:56 AM
So one aspect of the Facebook/Twitter and the Flurry plug-in is the Dictionary.<String, String> .... have had a look online and not sure exactly how to move a Dictionary.<String, String> to a hashtable within an action. Found this ...

var myHash = new Dictionary.<String, String>();
myHash.Add ("propertyname", "something");
// or
myHash["propertyname"] = "something";

So I assume the "propertyname" would be the key?! and the something would be the fsm variable?! (looking at the existing hashTable actions?
Title: Re: IOS Facebook/Twitter Prime[31] Actions
Post by: jeanfabre on August 06, 2013, 05:28:04 AM
Hi,

 If you are using ArrayMaker, study the hashtable actions, but basically your pseudo code is ok,  both variants are fine.

bye,

 Jean
Title: Re: IOS Facebook/Twitter Prime[31] Actions
Post by: escpodgames on August 10, 2013, 11:51:12 PM
Update -

I can now post to Facebook ... though I have one issue regarding if the Facebook app is installed things don't work unless you manually allow the app ... have asked Prime[31] about it. Waiting on response.
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: escpodgames on August 14, 2013, 07:50:12 AM
Ok so ... I'm guessing ill need a Proxy script to forward events to playmaker as PlayMaker events. .... interesting! (have been looking at the storekit actions :D
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: jeanfabre on August 14, 2013, 08:52:33 AM
Hi,

 yes. Also, look at how Photon is integrated. it has a lot of similar proxies ( especially on how to communicate then back to playmaker).

bye,

Jean
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: escpodgames on August 15, 2013, 07:12:22 PM
Took a look at the photon one and it was a bit over my head, but the storekit one was simple enough to follow and I can report that my Facebook one works :D

Next task is to figure out this hash table business :S and then facebook is done!
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: escpodgames on August 16, 2013, 12:04:12 AM
Have studied the hash table actions as much as I can but I'm still struggling to get this to work - included the getFriends action as it is now (totally doesn't work)

Any chance of pointing me in the right direction Jean? the main issue is getting the prime[31] completionHandler variables that can be added to the hash table.

Code: [Select]
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Prime31;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("IOS Facebook")]
[Tooltip("Get Facebook friends ID/Names.")]
public class Facebook_GetFriends : HashTableActions
{
[ObjectType(typeof(PlayMakerArrayListProxy))]
public FsmObject arrayList;

[ActionSection("Set up")]

[RequiredField]
[Tooltip("The gameObject with the PlayMaker ArrayList Proxy component")]
[CheckForComponent(typeof(PlayMakerArrayListProxy))]
public FsmOwnerDefault gameObject;

[Tooltip("Author defined Reference of the PlayMaker ArrayList Proxy component (necessary if several component coexists on the same GameObject)")]
[UIHint(UIHint.FsmString)]
public FsmString reference;

[ActionSection("Data")]

[RequiredField]
[Tooltip("The variable to add.")]
public FsmVar variable;

[RequiredField]
[UIHint(UIHint.FsmString)]
[Tooltip("The Key value for that hash set")]
public FsmString key;

[ActionSection("Result")]

[UIHint(UIHint.FsmEvent)]
[Tooltip("The event to trigger when element is added")]
public FsmEvent successEvent;

[UIHint(UIHint.FsmEvent)]
[Tooltip("The event to trigger when element exists already")]
public FsmEvent keyExistsAlreadyEvent;

public override void Reset()
{
gameObject = null;
reference = null;
key = null;
variable = null;
successEvent = null;
keyExistsAlreadyEvent = null;
}

public override void OnEnter()
{
if (SetUpHashTableProxyPointer(Fsm.GetOwnerDefaultTarget(gameObject),reference.Value))
{
if ( proxy.hashTable.ContainsKey(key.Value) )
{
Fsm.Event(keyExistsAlreadyEvent);
}
else
{
AddToHashTable();
Fsm.Event(successEvent);
}
}
Finish();
}

public void AddToHashTable()
{
if (! isProxyValid() )
return;
Facebook.instance.getFriends( completionHandler );
}

public void completionHandler( string error, object results )
{
if( error != null )
Debug.LogError( error );
else
{
myDictionary[key.Value] = variable.Value;
Prime31.Utils.logObject( results );
}
proxy.hashTable.Add(key.Value,PlayMakerUtils.GetValueFromFsmVar(Fsm,variable));
}
}
}
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: escpodgames on August 17, 2013, 01:25:25 AM
Bumb  :'(
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: jeanfabre on August 19, 2013, 03:40:32 AM
Hi,

 can you tell me more about what is the object results?

bye,

Jean
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: escpodgames on August 19, 2013, 03:51:19 AM
From the Prime[31] docs

// Sends a request to fetch the currently logged in users friends
public void getFriends( Action<string, object> completionHandler )

// common event handler used for all graph requests that logs the data to the console
CompletionHandler
Code: [Select]
void completionHandler( string error, object result )

{

if( error != null )

Debug.LogError( error );

else

Prime31.Utils.logObject( result );

}

What I'm wanting is the list of friends to be added to an array OR Hash Table as I assume that is what the completion Handler is. Getting it into the array has confused me greatly or even getting values.
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: jeanfabre on August 19, 2013, 03:59:24 AM
Hi,

 I don't own this plugin, so I can't really give you even pseudo code to being with if I don't know the content of the "result" variable.

bye,

Jean
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: escpodgames on August 19, 2013, 08:38:36 PM
Hi,

I totally understand.

Small update on the get friends action - after heaps of research, trial/many errors and writing a dll, I now have strong typed friends ...

So ignoring the plugin, I have a list of friends

friends[0].id
(id being a string)

How does one get that into the array? :S this is what I tried ..... but errors

friends[0].id = variable.Value;
proxy.Add(PlayMakerUtils.GetValueFromFsmVar(Fsm,variable),variable.Type.ToString());

OR

friends[0].id = variable.Value;
proxy.Add(variable.Value);
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: escpodgames on August 19, 2013, 09:55:50 PM
proxy.Add(object value, string type, silent bool);

what is the object value?
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: jeanfabre on August 20, 2013, 02:56:33 AM
Hi,

 Good, I am glad you are making progress!

 value can be any simple types: string, int, float, bool, rect, quaternion, vector2, vector3, texture. Basically, all the variable type you can create in Fsm Variables.

It can be something else, but then it won't show in the preview slot, and you won't be able to extract it in a Fsm Variable. but you can still work with any object value.

bye

Jean

Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: escpodgames on August 20, 2013, 03:54:11 AM
Ah, so the 'object value' is the string in this case and the string type ... um .. errr whats the string type? if I only use the object value it has an error saying it needs 2 arguments.
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: escpodgames on August 25, 2013, 05:08:32 AM
Bump - I hate bumping but I really need to figure this out, it's taken me way too long already :(
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: Synty on September 09, 2013, 08:39:18 AM
Any update on these actions?
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: escpodgames on September 09, 2013, 09:43:42 PM
Still stuck on adding the friends to array maker, haven't touched these actions in a few weeks just because I have to finish the rest of my game .. even though this is still very important. Not sure when these will be released yet.
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: jeanfabre on September 26, 2013, 06:38:22 AM
Hi,

Sent a email to you with some new actions.

 Basically, as a general hanlding strategy of Facebook graph return, I recommand the following approach:

 if your data content has only two rows, then use a hashtable, one row as the key and the other as the value,

 in case of fb friends, you have friendid and friendname. Simply put the friendid as key and then friendname as value within a hashtable and done.

 If you have more complex data with more rows basically, simply create as much arrayList as there are rows and inject in each the corresponding value. You will then be able to retrieve values for a specific index in that "list" made out of several arrayList.

 Say we had friends with date of birth too. we would have three rows to manager

friendId,FriendName,FriendDob

have three arrayLists, one for id, one for name and one for dob.

 find in the name arrayList, the index of a certain friend name, you can then get its date of birht ba getting the value in the dob arrayList under the same index.

Does that make sense?

bye,

 Jean
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: escpodgames on September 26, 2013, 07:18:47 AM
Hi,

Thanks heaps for this, had this on my list of things to test today, (building as I type) I think the best method is with the multi array as other people may need more info from the Facebook graph requests (this would need some editing to the dll) but nothing I couldn't add once my game is out and I have more time to clean it all up. I might make a 'getFriendsID' and 'getFriendsName' just in case people want to get more info, it will be easier to just add new action.

Building ..... and not working Hmmm.


Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: escpodgames on September 26, 2013, 07:52:06 AM
I'll try to get the facebook plug-in working in unity (like Mike has it in the vid I sent you) then I can test if the dll is working and break down where its not working. We'll get there :D
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: escpodgames on September 26, 2013, 08:18:04 PM
Have created a question on Prime31 support forum as I tracked it down to the P31DeserializeableField code he created in the video I linked. In Xcode it throws and exception even when in a non Playmaker environment.
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: jeanfabre on September 27, 2013, 01:38:49 AM
Hi,

 I am on it, please bump if I get side tracked.

bye,

 Jean
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: escpodgames on October 07, 2013, 03:52:56 AM
Bump :D
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: jeanfabre on October 07, 2013, 08:53:45 AM
arghh! :)

 I am on it!

Bye,

 Jean
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: Sonic Punch Studio on November 06, 2013, 04:32:18 AM
Hey there guys! I was just wondering, will those actions also work in Android games?

Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: jeanfabre on November 07, 2013, 01:42:52 AM
Hi,

 No, this is a "IOS" Prime[31] plugins, so that plugins only work on IOS. Check out the lsit of plugins, I think there is one for Android, but I never tested it.

bye,

 Jean
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: Marsh on December 25, 2013, 04:20:04 PM
If anyone is interested I made this plugin. I guess I should not have tried to upload to the unity Asset Store of the Christmas season as I have been waiting for a week and a half now with no word. iOS and Android are currently available. I can not make the bundle as I do not own that plugin and dont have $120.

It will be on the store for $15 when it gets approved. It may a bit annoying to have to pay for Prime31 tools and my plugin but a lot of work went into it. It also includes detailed documentation of how to setup a Twitter and Facebook application.

It can also receive friends lists as mentioned earlier in this thread. I have also added 2 non Prime31 actions that allow you to check if someone liked your page on Facebook and to follow a user on twitter.

If you want it early feel free to shoot me a pm.



I have also created a Prime31 Vungle Plugin for PlayMaker. If you have any ideas of a Prime31 plugin (or other) that you want actions created for feel free to pm me.
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: vicegold on April 01, 2014, 11:33:58 AM
Are you still working on the GameCenter Actions?
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: escpodgames on April 12, 2014, 08:13:18 PM
I have created the very basics which work, but im waiting for Marsh as he is actually a programmer
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: Marsh on April 12, 2014, 11:32:31 PM
I am actually not at the moment sorry. Taking a bit of a break from plugins.
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: escpodgames on April 12, 2014, 11:45:11 PM
We'll I have tried to do the advanced actions but, my coding skills are not up to scratch.
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: Marsh on April 14, 2014, 08:15:32 PM
What actions are you missing? The main problem for me is that I do not own a mac. So its a bit of a pain to VMWare everything.
Title: Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
Post by: escpodgames on April 14, 2014, 08:33:52 PM
Enough to do what the other Gamecenter plugin with actions can do. Would like to more all my scoring to Facebook so there isn't a need to have both googleplay and gamecenter have the same abilities (get the world rank of a player etc)