Hi, I'm trying to insert text into this textarea online.
I have two roads:
- POST method
- Web Browser method using Javascript
The POST vb.net code is
p.s. For a weird reason, if I don't use that random cookie and that header custom it won't save anything by decision from developers.
Web browser method using Javascript
I already had a look into the forum and in particular to OkHttpUtils2 / iHttpUtils2 / HttpUtils2 but to be honest I'm quite lost and all the examples seem differents from my case.
Thanks
I have two roads:
- POST method
- Web Browser method using Javascript
The POST vb.net code is
B4X:
Private Function RandomCookie() As String
Dim rnd(19) As Byte
Dim r = New Random()
r.NextBytes(rnd)
Return BitConverter.ToString(rnd).Replace("-", "").ToLower()
End Function
Private Function SaveData(ByVal data As String, ByVal urlKey As String, ByVal padKey As String) As Boolean
Const url As String = "https://notepad.pw/save"
Dim postData As New Specialized.NameValueCollection()
postData.Add("key", padKey)
postData.Add("pad", data)
postData.Add("url", urlKey)
postData.Add("pw", "")
postData.Add("monospace", "0")
postData.Add("caret", "0")
Try
Dim wc As New WebClient()
wc.Encoding = Text.Encoding.UTF8
wc.Headers.Add(HttpRequestHeader.Cookie, "pad_cookie=" + RandomCookie())
wc.Headers.Add("X-Requested-With", "XMLHttpRequest")
wc.UploadValuesAsync(New Uri(url), postData)
Return True
Catch ex As Exception
MsgBox("Error: " & ex.Message)
Return False
End Try
End Function
Sub Main()
' Esempio di uso:
Dim testo As String = "text text text"
Dim ok As Boolean = SaveData(testo, "011hk762", "63958th7q")
If ok Then
MsgBox("OK!")
End If
End Sub
p.s. For a weird reason, if I don't use that random cookie and that header custom it won't save anything by decision from developers.
Web browser method using Javascript
JavaScript:
var notepad = document.getElementsByTagName('textarea')[0];
// ottieni testo attuale
var text = notepad.value;
// aggiungi ciao
notepad.value = text + "ciao";
I already had a look into the forum and in particular to OkHttpUtils2 / iHttpUtils2 / HttpUtils2 but to be honest I'm quite lost and all the examples seem differents from my case.
Thanks