File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed
src/main/java/com/httpsms Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ dependencies {
5252 implementation ' com.beust:klaxon:5.5'
5353 implementation ' androidx.work:work-runtime-ktx:2.7.1'
5454 implementation ' androidx.appcompat:appcompat:1.4.2'
55+ implementation ' org.apache.commons:commons-text:1.9'
5556 implementation ' com.google.android.material:material:1.6.1'
5657 implementation ' androidx.constraintlayout:constraintlayout:2.1.4'
5758 testImplementation ' junit:junit:4.13.2'
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import okhttp3.MediaType.Companion.toMediaType
44import okhttp3.OkHttpClient
55import okhttp3.Request
66import okhttp3.RequestBody.Companion.toRequestBody
7+ import org.apache.commons.text.StringEscapeUtils
78import timber.log.Timber
89import java.net.URI
910import java.time.ZonedDateTime
@@ -63,9 +64,10 @@ class HttpSmsApiService(private val apiKey: String) {
6364 val formatter = DateTimeFormatter .ofPattern(" yyyy-MM-dd'T'HH:mm:ss.SSS'000000'ZZZZZ" )
6465 val timestampString = formatter.format(timestamp).replace(" +" , " Z" )
6566
67+
6668 val body = """
6769 {
68- "content": "$content ",
70+ "content": "${ StringEscapeUtils .escapeJson( content)} ",
6971 "from": "$from ",
7072 "timestamp": "$timestampString ",
7173 "to": "$to "
@@ -80,7 +82,7 @@ class HttpSmsApiService(private val apiKey: String) {
8082
8183 val response = client.newCall(request).execute()
8284 if (! response.isSuccessful) {
83- Timber .e(" error response [${response.body?.string()} ] with code [${response.code} ] while receiving message [${body} ]}] " )
85+ Timber .e(" error response [${response.body?.string()} ] with code [${response.code} ] while receiving message [${body} ]" )
8486 return
8587 }
8688
You can’t perform that action at this time.
0 commit comments