playMaker

Author Topic: IOS Facebook/Twitter/GameCenter Prime[31] Actions  (Read 18668 times)

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
IOS Facebook/Twitter/GameCenter Prime[31] Actions
« 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
« Last Edit: August 15, 2013, 10:05:51 PM by LampRabbit »

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: IOS Facebook/Twitter Prime[31] Actions
« Reply #1 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/

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: IOS Facebook/Twitter Prime[31] Actions
« Reply #2 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?
« Last Edit: August 04, 2013, 10:26:27 PM by LampRabbit »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: IOS Facebook/Twitter Prime[31] Actions
« Reply #3 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

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: IOS Facebook/Twitter Prime[31] Actions
« Reply #4 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.
« Last Edit: August 11, 2013, 01:43:55 AM by LampRabbit »

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
« Reply #5 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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
« Reply #6 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

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
« Reply #7 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!

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
« Reply #8 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));
}
}
}
« Last Edit: August 19, 2013, 03:53:09 AM by LampRabbit »

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
« Reply #9 on: August 17, 2013, 01:25:25 AM »
Bumb  :'(

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
« Reply #10 on: August 19, 2013, 03:40:32 AM »
Hi,

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

bye,

Jean

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
« Reply #11 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.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
« Reply #12 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

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
« Reply #13 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);
« Last Edit: August 19, 2013, 09:31:30 PM by LampRabbit »

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: IOS Facebook/Twitter/GameCenter Prime[31] Actions
« Reply #14 on: August 19, 2013, 09:55:50 PM »
proxy.Add(object value, string type, silent bool);

what is the object value?