I imagine posting to Twitter will be part of the Planner eventually, but in case anyone is interested, here’s how to get the Imp to post to Twitter using http://open.sen.se
I was wondering if you were @dawesduino ;) Very nice. Thanks for sharing, Brendan.
Thanks Nong.
I agree, thanks for sharing! I’ve modified parts of the code to hit ThingSpeak to get something posted to Twitter. The code in itself was an extremely helpful “learn by example” of how to make a push button web connected thing. I got far enough to prove to myself a working prototype…
Thanks for this. Helpful to get going.
I was able to knock the intermediate PHP out of the loop by manually constructing the JSON in the Squirrel code like follows:
channelOutput[0].set("{\"feed_id\":\"xxxxx\",\"value\":\"tweet\"}");
And POSTing from the vimp to api.sen.se with content type application/json.
Sean
Jumped the gun…doesn’t work…figuring it out.
Since doing this I’ve now removed the need to go through open.sen.se and instead use this library by Matt Harris: https://github.com/themattharris/tmhOAuth. I’ll post some code when I get chance.
Thanks for all the documentation Brendan. I’ve just got an imp and trying to get experimenting with it.
The Electric Imp whitepaper claims that they provide email and twitter gateways – is that just a lie?
We did provide email/twitter on an early planner revision, back when that was written. The whole IDE is being updated now, and agents will allow you the flexibility you need to connect to arbitrary services.
Thank you Hugo. I look forward to when the planner again allows me to both post to Twitter and react to tweets without third party services or self-hosted scripts. In the mean time I’ve been enjoying working through the examples and imagining what my impee could do.
Brendan (and/or Hugo):
I have attached a Planner screenshot to help…
I am trying to implement the above with the goal having a cat door that Tweets (basically sensing a switch closure). With the help of you and Hugo I have gotten pretty far, but now seem stuck. Probably due, in part, to the fact that I don’t fully understand the fundamentals of what is actually going on. That said, here is where I am at:
-
on Sen.se I have the Twitter API working. I can manually enter a value from Sen.se and it will Tweet on my page @OurCatDoor. I have established my Imp as a device in Sen.se and have the FEEDID and API Code.
-
In Imp Planner I have switch closure (PIN1 to GND) code that works.
-
In Imp Planner I have the switch code ‘noddled’ to the “OPENSENSE.PHP” file on my server (with proper FEEDID and API codes). I modified the Imp code some for debug by adding a timestamp to the switch closure (see pic)
-
The HTTP node with the FEEDID/API modified PHP returns “200” which in my book means “All OK”.
But (and of course you could have guessed this), a switch closure on the Imp does not force the Sen.se to send the tweet.
I’m “shotgunning” the problem now, so thought I would pause for some help from those that are wiser. Any thoughts on what I am missing. Something tells me it is with the ‘noodle’ setup.
Planner screenshot attached at and at:
Thanks,
Update: I got to thinking… I believe the issue is with server (ISP) not allowing script to run on their site. I should have thought of this straight away.
I’ll dust off an old PC an create a little server, I guess. I wish Electric Imp would support access to Twitter directly. Seems like one of the most convient ready made solutions for broadcasting status easily.
I welcome comments…
Agents will allow you to do this; right now you tend to need to cobble stuff together for external services I’m afraid
OK. Update here… First off a few ‘grounding’ statements:
- this is my first Imp
- first use of Squirrel code
- first PHP exposure.
- 75% of the info came from this forum or the devwiki. 25% from other random web pages.
Result:
It’s working. I connect PIN1 to GND. The Imp sees it, the PHP script is triggered, and our cat door twitter page gets updated.
Well, for now anyway.
Pretty impressive piece of kit and pretty impressive support forum.
Build page at: http://whiskeytangohotel.com/ourcatdoor
Nice one.
Thanks brendandawes for the comment and thanks for your help!
Source on build page updated to correct some error hits.
Use two magnetic reed switches on the door so you know if it swung from the inside out, or the outside in. One switch will trigger a few milliseconds before the other.
And debounce them so the door swinging back and forth after use doesn’t trigger.
These types of projects are always amusing.
With Agent it is a few lines of code to do Facebook updates…