Skip to content
Browse files

added parameters for to phone number and message

  • Loading branch information...
1 parent cb71dde commit 0579ff471ba9995008d3978b8d6e371db9a184f4 @SidneyAllen committed Aug 2, 2012
Showing with 23 additions and 7 deletions.
  1. +23 −7 java/src/main/java/com/stackmob/example/TwilioSMS.java
View
30 java/src/main/java/com/stackmob/example/TwilioSMS.java
@@ -34,7 +34,7 @@
import com.stackmob.sdkapi.LoggerService;
import java.net.HttpURLConnection;
-import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -56,18 +56,34 @@ public String getMethodName() {
@Override
public List<String> getParams() {
- return new ArrayList<String>();
- }
+ return Arrays.asList("tophonenumber","message");
+ }
@Override
public ResponseToProcess execute(ProcessedAPIRequest request, SDKServiceProvider serviceProvider) {
LoggerService logger = serviceProvider.getLoggerService(TwilioSMS.class);
- // The TO phonenumber should be YOUR cel phone
- // The FROM phonenumber should be one create in
- // the twilio dashboard at twilio.com
- String body = "To=4152221212&From=9253334545&Body=hello";
+ // TO phonenumber should be YOUR cel phone
+ String toPhoneNumber = request.getParams().get("tophonenumber");
+
+ // FROM phonenumber should be one create in the twilio dashboard at twilio.com
+ String fromPhoneNumber = "YOUR_TWILIO_NUMBER";
+
+ // text message you want to send
+ String message = request.getParams().get("message");
+
+
+ if (toPhoneNumber == null || toPhoneNumber.equals("")) {
+ logger.error("Missing to phone number");
+ }
+
+ if (message == null || message.equals("")) {
+ logger.error("Missing message");
+ }
+
+
+ String body = "To=" + toPhoneNumber + "&From=" + fromPhoneNumber + "&Body=" + message;
int responseCode = 0;
String responseBody = "";

0 comments on commit 0579ff4

Please sign in to comment.
Something went wrong with that request. Please try again.