Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CloudRail example code how to combine the VersionEye API with the Twilio API through the CloudRails SDK.
//Create all needed imports
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
import com.cloudrail.exception.CloudRailException;
import com.cloudrail.userInterface.TextOnUpdate;
//These two are the event listeners for the functions in our Custom CloudRail API
import com.cloudrail.userInterface.TextOnUpdate.GetPackageInfoResponseListener;
import com.cloudrail.userInterface.TextOnUpdate.SendSMSResponseListener;
public class SendTextOnUpdate {
public static void main(String[] args) throws UnsupportedEncodingException {
final String versioneyeapikey = "ABCDE123"; //Replace with your own VersionEyeAPIKey
//The following block are the items we need to use the Twilio Integration
final String sender = "+15005550006"; // Change to the number you are sending from
final String recipient = "+78798"; // Change to the number you are sending to
/*
* The next line needs to be within Base64 format.
* To do this, go to https://www.base64encode.org/, and insert in
* Your API key and your account ID, seperated out with a colon, like this
* TwilioApiKey:AccountsId And paste the results into the varable below.
*/
final String apikey = "ABCDE123"; // Change to your API key
final String accountsid = "ABCDE123"; //Change to your own Twilio account ID
//-------------------------
// These are the variables we will be using for a project ID and a
// previous version number. Of course, in a real program
// These would be obtained in some other way.
final String packagekey = "firebase/angularfire";
final String programminglang = "javascript";
final String packageversion = "1.1.4";
final String textlastsent = "2016-02-23T03:07:37.227Z";
TextOnUpdate textupdatesclass = new TextOnUpdate(versioneyeapikey); // We pass our global variable to the constructor here
textupdatesclass.getPackageInfo(packageversion, programminglang, packagekey, new GetPackageInfoResponseListener(){
@Override
public void onSuccess(String description, List<Object> dependencies_list, List<Object> licenses_list, String updatedat, String licenseinfo, String prodkey) {
if (!updatedat.equals(textlastsent)) {
textupdatesclass.sendSMS(sender, recipient, "Package has Updated", apikey, accountsid, new SendSMSResponseListener(){
@Override
public void onSuccess() {
System.out.println("Text was Sent!");
}
@Override
public void onError(CloudRailException error) {
System.out.println(error);
}
@Override
public void onProgress(double percentFinished) {
// TODO Auto-generated method stub
}
});
} else {
System.out.println("No Update!");
}
}
@Override
public void onError(CloudRailException error) {
error.printStackTrace();
}
@Override
public void onProgress(double percentFinished) {
// TODO Auto-generated method stub
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.