Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: laynardo on February 29, 2016, 09:35:17 PM

Title: Twitter?
Post by: laynardo on February 29, 2016, 09:35:17 PM
If anyone knows how to get twitter searches and posts into Playmaker, I would love to hear it.
Title: Re: Twitter?
Post by: jeanfabre on March 02, 2016, 02:58:48 AM
Hi,

 What do you mean? I have a twitter account (https://twitter.com/JeanAtPlayMaker) dedicated to PlayMaker.


Or do you mean inside your project as a feature to expose to your players?

Stan's asset (https://www.assetstore.unity3d.com/en/#!/content/7421) has support for twitter and PlayMaker.

Bye,

 Jean
Title: Re: Twitter?
Post by: laynardo on March 02, 2016, 08:46:38 AM
I want to pull a search on twitter, and display it within Unity. Either as an actual string or a trigger to make something happen. For example, anytime someone uses the word "love" in a tweet, I want X to happen in Unity.

This is something I used to be able to do when Twitter was easily searchable with an XML feed, but they changed their API.
Title: Re: Twitter?
Post by: jeanfabre on March 03, 2016, 01:49:32 AM
Hi,

 That's something you'll need to check with twitter asset's provider like Stan. I haven't worked with twitter api deeply enough to be of any help here. Sorry :)

Bye,

 Jean
Title: Re: Twitter?
Post by: laynardo on March 03, 2016, 09:54:56 AM
got it. checking it out
Title: Re: Twitter?
Post by: laynardo on March 06, 2016, 06:48:04 PM
Stan's just posts to twitter seems like. I actually need to do a twitter search and display the tweets in game.
Title: Re: Twitter?
Post by: dudebxl on March 06, 2016, 07:33:18 PM
On twitter api website, it says you can search tweets by using a json query ( u have to build it) You should be able to build a json query, wwwpost, get result as another json.. You have to have a twitter dev account.. Or user need to open account..

Search Get search/tweets api on google..
Title: Re: Twitter?
Post by: laynardo on March 06, 2016, 07:42:15 PM
yea, i went through that and setup a dev account. unfortunately, i think it's over my head. It gives me this stuff (attached).

side note- i do know how to use datamaker to parse out xml/json info. I am doing that for weather underground. but with weather underground, you just put your api key in the url.
Title: Re: Twitter?
Post by: dudebxl on March 07, 2016, 12:36:26 PM
sorry, can't help. no idea.
Title: Re: Twitter?
Post by: laynardo on March 07, 2016, 03:09:24 PM
hah! it's cool. whenever I figure it out, I will post the answer.  :)
Title: Re: Twitter?
Post by: dudebxl on March 13, 2016, 01:57:19 PM
have you tried this: https://bitbucket.org/gambitforhire/twitter-search-with-unity/downloads
Title: Re: Twitter?
Post by: laynardo on March 13, 2016, 03:27:45 PM
I tried to yea. I just couldn't figure it fully out. I put in all four of my keys into the component, but wasn't sure where to go from there in playmaker.
Title: Re: Twitter?
Post by: dudebxl on March 13, 2016, 04:13:18 PM
Lol, yeah same here.. It works but can't figure out how to adapt it for my own use (change query etc)..  ???
Title: Re: Twitter?
Post by: dudebxl on March 14, 2016, 04:28:02 PM
I was able to understand and convert the code to playmaker.

This is an alpha. Let me know if it works on your side (it works for me but only tested GET as that is all i need for my project) so that i can post on ecosystem. In theory it should work with everything from https://dev.twitter.com/rest/public - all GET and POST query and works inside editor.

How to make a query:

'(Parameters=Value)'
For example: (q=Ufo)(count=100)(result_type=popular)
with
setTwitterUrl = https://api.twitter.com/1.1/
setTwitterUrlType = search/tweets.json

will produce the Raw Json data (then you need Datamaker)

Let me know thanks..


Will post on ecosystem a final version soon.
Title: Re: Twitter?
Post by: jeanfabre on March 15, 2016, 01:51:13 AM
Hi,

 Nice, thanks for this. Haven't tested it, but I'll sure use that when I'll do.

Bye,

 Jean
Title: Re: Twitter?
Post by: dudebxl on March 15, 2016, 04:04:40 PM
Cool
.. let me know if it works for you. thx
Title: Re: Twitter?
Post by: laynardo on March 19, 2016, 09:51:02 PM
ok. so i get a "WWW object is null!" in the error string. Did I do my query wrong? Do I need to add a WWW object before this Action?
Title: Re: Twitter?
Post by: dudebxl on March 20, 2016, 12:35:46 PM
Laynardo please read the intro i made. No point writing how to use something if you don't read then wonder why it does not work.

For example: (q=Ufo)(count=100)(result_type=popular)

if you want only ufo then it would be (q=Ufo) - also read the twitter api documentation so that you can understand what q= means because again if you took the time to read api doc (and my intro) you would not be asking why it does not work.

 :P
Title: Re: Twitter?
Post by: laynardo on March 20, 2016, 02:15:48 PM
Yea, I read it. and the twitter documentation. I tried plugging the query in a bunch of different formats, including that one you listed above. Just plugging UFO in was a last try I guess. I'll figure it out, and truly appreciate your help. I'll keep you guys posted when I figure out. Sorry if I sound dumb :o
Title: Re: Twitter?
Post by: dudebxl on March 20, 2016, 02:35:54 PM
You are not dumb !! but you did not explain well your situation.  So what is the problem.. Let's break it down..

The query will only work is this format (Parameters=Value) so each open/close bracket is a section of the query. so you build each section of the query with the open/close bracket.

If you use the Query (keep everything the same except replace Ufo in query with this):  (q=Ufo)(count=2)(result_type=popular)

Do you get the json results?
Title: Re: Twitter?
Post by: laynardo on March 20, 2016, 03:01:15 PM
I replaced the ufo query with (q=Ufo)(count=2)(result_type=popular), and kept everything else the same. I didn't get any json results, I don't think. Here is a screenshot.
Title: Re: Twitter?
Post by: dudebxl on March 20, 2016, 04:01:30 PM
Ok... Try with debug on.. don't publish here the result but check if the oauth is correct (all your keys are correct/good) and that you are connecting. You are getting an error (if it was working you would get a no result from twitter or something in the Json field).

Title: Re: Twitter?
Post by: laynardo on March 20, 2016, 05:21:46 PM
oookkk... so i triple checked all my keys. one of them had an extra space at the end. I am getting data now.

I just need to figure out how to convert that to xml in datamaker now.I know there is a Convert Json String To Xml Node, i just need to figure out how to use it. I'll keep you posted.
Title: Re: Twitter?
Post by: dudebxl on March 20, 2016, 06:24:20 PM
cool,

so you confirm that it is working then? If yes than i will post on ecosystem..

thx
Title: Re: Twitter?
Post by: laynardo on March 20, 2016, 06:26:25 PM
it works! I converted it to xml with datamaker, and am parsing out nodes successfully. This is amazing!
Title: Re: Twitter?
Post by: jeanfabre on March 23, 2016, 03:12:58 AM
Excellent news!

 Bye,

 Jean
Title: Re: Twitter?
Post by: calculmentor on March 23, 2016, 06:47:41 AM
AMAZING!!!!!!
works here like a charme!
thx
n.
Title: Re: Twitter?
Post by: laynardo on March 23, 2016, 11:32:29 AM
I am going to look into how to remove the URL it adds at the end. I couldn't find anything in the API docs yet to just turn it off. I know twitter wants it in there.
Title: Re: Twitter?
Post by: dudebxl on March 23, 2016, 01:04:18 PM
@laynardo

I am trying to use datamaker with the twitter Json. Could I ask for a favour. Could you explain to me how you would get for example the text data from json result. i have never used datamaker and I would be good to get a bit of guidance.

+ i would like to publish the explanation (if you are willing to the twitter api forum page) so that new users understands how to fully use it. :)

or mdotstrange, if you want to give it a try, please do.. :)


figured it out by watching this: from mdotstrange, many thanks for it..  :D
Title: Re: Twitter?
Post by: laynardo on March 23, 2016, 06:10:13 PM
oh! hah. I was getting to write it out, but yea, that is the same video I watched. Some things that I did notice, and still working through are:
-Having trouble with the data refreshing, haven't gotten that to work yet. Even on loop. It only refreshes after each build.
-Removing the t.co url from the string somehow.
Title: Re: Twitter?
Post by: dudebxl on March 23, 2016, 09:01:07 PM
Try with this in your query: since_id  && result_type=recent

For me, it refresh result when I use this..
Title: Re: Twitter?
Post by: laynardo on March 24, 2016, 12:22:08 PM
yea, i tried that. i think it just something simple in FSM that I am doing wrong. I am going to attach it here.
Title: Re: Twitter?
Post by: dudebxl on March 24, 2016, 12:39:52 PM
Yeah can you upload a picture. i don't like opening packages as they always mess up my projects... and my computer is very slow so each time i open unity, i have to wait ages.
Title: Re: Twitter?
Post by: laynardo on March 24, 2016, 06:35:21 PM
here you go. i can add some more shots if that helps
Title: Re: Twitter?
Post by: dudebxl on March 25, 2016, 09:19:58 AM
I have an extremely similar fsm setup in my project and I am able to refresh the data so I think it is the query.

- Have you tried with a diffrent and very popular q=?
- Are you using since_id with your new timestamp on each request?
- are you result_type=recent?
Title: Re: Twitter?
Post by: laynardo on March 25, 2016, 11:30:46 AM
In the datamaker xml proxy, I actually see the xml getting updated. But for some reason it's not populating the hashtable with the updated nodes. I am even clearing the hashtable at the last state of the FSM, and it just populates the old tweets again.

I am wondering if i just move the Xml Select Nodes to a new state, if it will just work.
Title: Re: Twitter?
Post by: dudebxl on March 25, 2016, 11:38:49 AM
ah.. ok i can't help. i only used datamaker once. I can help with the twitter api action but for datamaker you should ask JeanFabre or mdotstrange (if willing).

Maybe the variable is not correct. Do a frame by frame debug in playmaker and check each variable at each state.

sorry
Title: Re: Twitter?
Post by: jeanfabre on March 25, 2016, 02:30:49 PM
Hi,

 uhm, maybe you need to wait one frame for sure once you parsed it. try this and get back to me if that doesn't work.

Bye,

 Jean
Title: Re: Twitter?
Post by: laynardo on March 25, 2016, 04:48:47 PM
yea. tried that. you mean one blank state, or a wait for like one second?
Title: Re: Twitter?
Post by: laynardo on March 25, 2016, 05:25:48 PM
the hashtable data doesn't get populated with new data. Even when I can see the xml data being updated in the proxy. It just re-adds the same data from when I hit Build. It's like it's being stored somewhere after the first run through or something.
Title: Re: Twitter?
Post by: jeanfabre on March 28, 2016, 02:08:58 AM
Hi,

 I'll have a go at all this, and let you know how it goes.

 Bye,

 Jean
Title: Re: Twitter?
Post by: jeanfabre on March 29, 2016, 02:59:26 AM
Hi,

 ok, I tested and it all works properly, here's few tips to debug this on your end.

-- ALWAYS implement all events from xml actions ( Found, Not Found, Error), it's critical to keep sanity in your project and mind... so the first thing to do is to route each xml actions with proper transitions for each potential outcome.

once you have done this, run it, and see if indeed xml is being parsed properly and that your xpath queries lead to valid searches within the xml.

then if all of this works, try the following:

1: get the twitter result
2: use ConvertJsonStringToXml and save it into your proxy
3: use XmlGetNodeProperties using that proxy as the source with the following property: "/search_metadata/count" save that value into a Fsmstring called "Count".

run this, you should have a value inside "Count".

 no need to wait one frame or anything weird, just go from state to state as per usual.

Let me know how it goes.

Bye,

 Jean
Title: Re: Twitter?
Post by: laynardo on April 24, 2016, 08:24:38 PM
I get the right value inside my count. My proxy live updates with new content every time I loop back to start- it's my hashtable that isn't updating after the first loop.
Title: Re: Twitter?
Post by: jeanfabre on April 25, 2016, 01:23:51 AM
Hi.

 Why looping back?

Bye,

 Jean
Title: Re: Twitter?
Post by: laynardo on April 25, 2016, 10:01:02 AM
I want to live update the tweets, so they aren't the same six for the entire time. so i loop back to start to refresh everything.
Title: Re: Twitter?
Post by: jeanfabre on May 06, 2016, 01:58:54 AM
Hi,

 Ok, can you send me a package with a sample scene showing your setup, I think there may be something I am overlooking that is the key to make your system work.

Bye,

 Jean
Title: Re: Twitter?
Post by: laynardo on May 06, 2016, 10:45:53 AM
Here you go. I assume it's something simple I am missing.
Title: Re: Twitter?
Post by: jeanfabre on May 20, 2016, 02:30:50 AM
Hi,

 It's odd, your package scene is totally empty. what version of Unity are you using?

Bye,

 Jean
Title: Re: Twitter?
Post by: laynardo on May 20, 2016, 03:26:24 PM
weird. i just downloaded it form here and tested it. it imports the scene into folder called _Scenes if that helps.

There won't be anything in the Scene/Game window but some canvas text, since all we are testing is twitter.
Title: Re: Twitter?
Post by: jeanfabre on May 21, 2016, 03:46:22 AM
Hi,

 What version of Unity did you packaged with?

Bye,

 Jean
Title: Re: Twitter?
Post by: laynardo on May 21, 2016, 11:22:08 AM
5.3.4f1
Title: Re: Twitter?
Post by: laynardo on May 22, 2016, 10:27:52 PM
any luck?
Title: Re: Twitter?
Post by: jeanfabre on May 23, 2016, 03:45:21 AM
Hi,

Yep, It's because you need to use the "Reset" property of the "Xml Get Next Node List Properties" action.

 So before you enter the state "Get node properties" you raise a "Reset" FsmBool to true, and inject that into the "Xml Get Next Node List Properties" so that it knows you want to start from scratch again.

 and then you'll be looping properly on your new results, not just the original one.

 Bye,

 Jean
Title: Re: Twitter?
Post by: laynardo on June 07, 2016, 10:23:20 PM
so I did a Set Bool Value, in the Select Node state. And created a variable called "resetTweets". And I call the variable in the Get Node Properties state under  Xml Get Next Node List Properties action. But for some reason the Xml Get Next Node List Properties keeps setting the variable to False.
Title: Re: Twitter?
Post by: jeanfabre on June 08, 2016, 01:54:45 AM
Hi,

 In my tests it worked. Have you reference "resetTweets" in the XmlGetNextNodeList action? you should raise it to false before entering the state, and then the action will set it to false, so verify that your "resetTweets" is true before entering and false straight after having been dealt by XmlGetNextNodeList

Bye,

 Jean
Title: Re: Twitter?
Post by: laynardo on June 08, 2016, 11:06:17 AM
hmm. maybe it's something else that is conflicting with my FSM working right. I attached my updated one.