This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group 'uk.co.placona' | |
version '1.0-SNAPSHOT' | |
buildscript { | |
repositories { jcenter() } | |
dependencies { | |
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3' | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static spark.Spark.*; | |
public class SMSBackend { | |
public static void main(String[] args) { | |
get("/", (req, res) -> "Hello, World!"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ngrok http 4567 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.twilio.sdk.TwilioRestClient; | |
import com.twilio.sdk.resource.instance.Sms; | |
import java.util.HashMap; | |
import java.util.Map; | |
import static spark.Spark.*; | |
public class SMSBackend { | |
public static void main(String[] args) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
compile fileTree(dir: 'libs', include: ['*.jar']) | |
testCompile 'junit:junit:4.12' | |
compile 'com.android.support:appcompat-v7:23.3.0' | |
compile 'com.squareup.okhttp3:okhttp:3.2.0' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="uk.co.placona.twiliosms"> | |
<uses-permission android:name="android.permission.INTERNET"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:paddingBottom="@dimen/activity_vertical_margin" | |
android:paddingLeft="@dimen/activity_horizontal_margin" | |
android:paddingRight="@dimen/activity_horizontal_margin" | |
android:paddingTop="@dimen/activity_vertical_margin" | |
tools:context="uk.co.placona.twiliosms.MainActivity"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package uk.co.placona.twiliosms; | |
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.EditText; | |
import android.widget.Toast; | |
import java.io.IOException; | |
import okhttp3.Call; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Call post(String url, Callback callback) throws IOException{ | |
RequestBody formBody = new FormBody.Builder() | |
.add("To", mTo.getText().toString()) | |
.add("Body", mBody.getText().toString()) | |
.build(); | |
Request request = new Request.Builder() | |
.url(url) | |
.post(formBody) | |
.build(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mSend.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
try { | |
post(mContext.getString("YOUR_NGROK_URL/sms"), new Callback(){ | |
@Override | |
public void onFailure(Call call, IOException e) { | |
e.printStackTrace(); | |
} |