Hi,
it took me a while to get the project working. I planned to make a Facebook profile to post pictures from Arduino Yun and use likes and comments to light up the leds. However Facebook has new policies regarding applications, now it's necessary to pass an approval process that takes a week and they didn't approved mine (it should be a web app and not an object) . I used the Temboo apis but the problems is that the images posted are private, the support confirmed me the problems with the new Fb policies. So I used a workaround posting on Twitter and linking the account to Facebook https://www.facebook.com/profile.php?id=100008703930280.
I attach the code I used on the Yun. It's a python script based on the example of Arduino Yún social photo camera | MIKAMAYHEM used to upload the pictur shooted using fswebcam.
# coding=utf-8 # Copyright (C) 2014 Stefano Guglielmetti # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import base64 import sys from temboo.core.session import TembooSession from temboo.Library.Twitter.Tweets import UpdateWithMedia print str(sys.argv[1]) with open(str(sys.argv[1]), "rb") as image_file: encoded_string = base64.b64encode(image_file.read()) # Create a session with your Temboo account details session = TembooSession("account", "myFirstApp", "key") # Instantiate the Choreo updateWithMediaChoreo = UpdateWithMedia(session) # Get an InputSet object for the Choreo updateWithMediaInputs = updateWithMediaChoreo.new_input_set() #inputs updateWithMediaInputs.set_MediaContent(encoded_string) updateWithMediaInputs.set_AccessToken("mytoken") updateWithMediaInputs.set_AccessTokenSecret("mysecret") updateWithMediaInputs.set_Latitude("41.9000") updateWithMediaInputs.set_ConsumerSecret("consumer secret") updateWithMediaInputs.set_Longitude("12.5000") updateWithMediaInputs.set_StatusUpdate("Foto scattata alle " + print (time.strftime("%H:%M:%S")) + " Buone Feste!") updateWithMediaInputs.set_ConsumerKey("consumer key") updateWithMediaInputs.set_DisplayCoordinates("true") # Execute the Choreo updateWithMediaResults = updateWithMediaChoreo.execute_with_results(updateWithMediaInputs) # Print the Choreo outputs print("Response: " + updateWithMediaResults.get_Response()) print("Limit: " + updateWithMediaResults.get_Limit()) print("Remaining: " + updateWithMediaResults.get_Remaining()) print("Reset: " + updateWithMediaResults.get_Reset())
As I have some troubles reading likes from Facebook now the leds light up con confirm that the picture was uploaded.
Here is the sketch, the picture is shoot when two people hold a branch of the tree and then touch each other.
#include <Process.h> const int buttonPin = 10; // pin for the pushbutton const int ledPin = 13; // pin for the status led String path = "/mnt/sda1/"; String file = "/www/sd/fotop.png"; // path of the images and script file String messaggio = ""; void setup() { // put your setup code here, to run once: Bridge.begin(); // The bridge library is used to run processes on the linux side pinMode(ledPin, OUTPUT); pinMode(buttonPin, INPUT); Serial.begin(9600); // Serial port for debugging //filename = "test"; } void loop() { // put your main code here, to run repeatedly: int btn = digitalRead(10); int tocco = analogRead(A0); if(tocco < 800){ // Serial.println("contatto"); digitalWrite(13,HIGH); }else{ digitalWrite(13,LOW); } Serial.println(tocco); delay(5); if(btn == HIGH){ Serial.println("premuto"); Process p; messaggio = "Foto scattata"; p.runShellCommand("fswebcam -c ~/.fswebcam.conf"); //let's take the picture while(p.running()); //waits till the picture is saved Serial.println(messaggio); delay(5000); p.runShellCommand("python " + path + "sendphoto_tw.py " + file ); //sends the picture to facebook while(p.running()); Serial.println("picture sent"); //last debug message } }