Sending sms to multiple phonenumbers using mysms API - api

I'm trying to send sms using mysms API. I am able to send to single number using following example:
Example: https://api.mysms.com/json/message/send?api_key=xxxxx&msisdn=xxx&password=xxx&recipient=436761234567&message=Hi
How can I send to multiple number using above example?

I came up with this code:
function sendSMS() {
var apikey = "your api_key";
var mno = 40123123456; // msisdn = your number without +sign in from
var pwd = "yourpassword";
// var no = 40123123456; // single number & replace this with a real one
var grp = [40123123456,40123123456,40123123456]; // multiple numbers / let's call it a group & just replace those with your actual testing numbers
var msg = "Hi!%0aThis is a test message!%0aThis is another row.%0a:D"; // Use %0a to insert a new row in your message
for ( var i in grp ) {
var smsurl = "https://api.mysms.com/json/message/send?api_key="+apikey+"&msisdn="+mno+"&password="+pwd+"&recipient="+grp[i]+"&message="+msg+"";
var xhttp = new XMLHttpRequest();
xhttp.open("GET", smsurl, true);
xhttp.send();
console.log(smsurl);
}
}
Now just make the call:
sendSMS();
This code is javascript and I hope will answer your question well. Also it was tested and proven that is working. There is always room for improvements.

Related

Import CSV from API output to google

I have absolutly no idea of what I'm doing but I'm trying to import CSV data from API output into a google sheets.
The data I want to import are bookings data, aleady generated as a csv file and I simply need to import all the data the first time and then update it (no need to re-import all the datas from last year)
The API URL is:
https://www.beds24.com/api/csv/getbookingscsv
I need however to enter my username and my password and if necessary a date range.
So in my head it would be:
One script for the year booking import
username XXXXX
password •••••
datefrom
dateto
One script for the day booking import using the date range
username XXXXX
password •••••
datefrom 2019-09-29
dateto 2019-09-29
The first look I took using googlescript I found out that I would probably need something like this:
function importCSV() {
var var bookings = beds24api.beds24GetBookings(prop_key, data_option);
var res = UrlFetchApp.fetch("https://www.beds24.com/api/csv/getbookingscsv");
var content = res.getContentText();
var authentication = {
'authentication' : {
'username' : XXXXX,
'password' : •••••
};
};
}
function beds24GetBookingsCSV(username, password, data_option){
return beds24JsonApi('https://www.beds24.com/api/csv/getbookingscsv',username, password, data_option);
};
return {
beds24GetBookings: beds24GetBookingsCSV,
};
}
Lot of you gonna get bleding eyes from this code but if I could get some help acheiving this that would be awesome!
I have no experience with beds24 nor do I wish to. But if you look here you will find an example of UrlFetchApp.fetch(url, options);. I believe that you'll need to include your authentication data into the options object or include them as elements of the querystring portion of the url. Look to see in beds 24 has a Google Apps Script example or possibly a Javascript example.
String url = "https://www.beds24.com/api/csv/getbookingscsv";
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod("POST");
String params = "username=XXX&password=YYY";
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(params);
wr.flush();
BufferedReader in = new BufferedReader( new InputStreamReader(con.getInputStream()));
StringBuilder response = new StringBuilder();
String inputLine;
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
System.out.println(response.toString());
# Function to get data from Beds24 API
getBeds24Data <-function(username = property_mgmt$username,
password = property_mgmt$password,
datefrom = "2019-01-01",
dateto = "2019-12-30"){
url <- "https://www.beds24.com/api/csv/getbookingscsv"
response <- httr::POST(url=url, body = list("username" = username,
"password"=password,
datefrom = datefrom,
dateto = dateto))
beds24Data <- httr::content(response,type='text/csv',col_names=T,col_types=NULL)
return(beds24Data)
}

Google Apps Script query to MariaDB

We recently moved our data to a new server - however the new one is using MariaDB.
We do a lot of queries and calculations in Google Apps Script for spreadsheet. Since the server switch our scripts return the following error:
Unknown system variable 'OPTION' (line 21, file "")
Line 21 refers to the query inside the following script:
function mysql_invoice() {
// Replace the variables in this block with real values.
var address = 'xxx';
var user = 'xxx';
var userPwd = 'xxx';
var db = 'xxx';
var dbUrl = 'jdbc:mysql://' + address + '/' + db;
// Read up to 100000 rows of data from the table and log them.
var conn = Jdbc.getConnection(dbUrl, user, userPwd);
var stmt = conn.createStatement();
// Call SO DATA
stmt.setMaxRows(10000);
var start = new Date();
var rs = stmt.executeQuery("select * from sales_flat_invoice");
Any ideas?
I believe the way you used setMaxRows is the problem.
If you change the way you set the limit it will work.
// Call SO DATA
// stmt.setMaxRows(10000);
var start = new Date();
var rs = stmt.executeQuery("select * from sales_flat_invoice limit 10000");
This should fix your problem. This definetly comes from the missmatch of version of your MariaDB and the version of jdbc connector.
Cheers

How do I correct the "Object Expected" Error when it inloves var queryStringVals = $().SPServices.SPGetQueryString();?

Hi have been getting an error stating.. Object Expected for these 2 lines of code:
function AsyncSave(send) {
//alert ('In CustomSave');
var drp = document.getElementById("Sample_sample_DropDownChoice");
var drpValue = drp.options[drp.selectedIndex].value;
var varAnalysis = getTagFromIdentifierAndTitle("textarea","TextField","Principal Comments");
var varAnalysisTextBoxID = RTE_GetEditorDocument(varAnalysis.id);
var varAnalysisText = varAnalysisTextBoxID.body.innerText;
alert ('Save N Send');
alert (drpValue);
alert (varAnalysisText);
Error Happens when it gets to the line below
var queryStringVals = $().SPServices.SPGetQueryString();
var itemID = queryStringVals["itemID"];
What could be the problem.. should I be running different up to date SPServices.. this is 2010 btw.
The goal is to take the values entered, save them, and update them (send) to another form/List.
SharePoint 2010 has a built-in JavaScript method for retrieving values from the query string. Try using the following:
var itemID = GetUrlKeyValue("itemID");
That's assuming the URL of the page on which the script is running actually has a query string parameter of "itemID"

sending string parameter in action=track leanplum Rest Api not working

I want to send string parameters in Leanplum api using action script
Eg param:{"Element":"Hi"}
var request:URLRequest = new URLRequest("https://www.leanplum.com/api");
request.method = URLRequestMethod.GET;
var variables:URLVariables = urlVariables;
variables.userId = userId;
variables.event = eventName;
var params:Object = new Object();
params.Element = "Hi";
var paramStr:String = JSON.stringify(params);
variables.params = paramStr;
variables.appId = appId;
variables.clientKey = clientKeyProduction;
variables.apiVersion = apiVersion;
variables.action = "track";
variables.versionName = AppInfo.getInstance().appVersion;
request.data = variables;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, function(e:Event):void {
trace(e.target.data);
});
loader.addEventListener(IOErrorEvent.IO_ERROR, function(e:IOErrorEvent):void {
trace(e.target.data);
});
loader.load(request);
This is actual Request (App ID and ClientKey are dummy):
https://www.leanplum.com/api?clientKey=V42fKaJaBuE&userId=1010&params={"Element":"Ur"}&appId=HEVdDlXiBVLwk&event=Element_Opened&action=track&versionName=2.3.0&apiVersion=1.0.6&info=Lu
Encoded Request:
https://www.leanplum.com%2Fapi%3FclientKey%3DV42fKaJaBuE%26userId%3D1010%26params%3D%7B%22Element%22%3A%22Ur%22
%7D%26appId%3DHEVdDlXiBVLwk%26event%3DElement_Opened%26action%3Dtrack%26versionName%3D2.3.0%26apiVersion%3D1.0.6%26info%3DLu
if I run above request in any rest client I get the same status success : true .
I am getting the response {"response": [{"success": true}]} but I can't find the parameters with value string in Leanplum dashboard, its listing parameter name but not the String Value for parameter.
If you apply some combination of filters then you can see values of parameter you sent to leanplum. like First select the occurrence of some event then apply Group by parameter then select parameter you want to see the data for.
Its a little different from flurry, Google analytics etc.

Post values in URL are not set because of special characters in Web API

I'm trying to pass a string with special characters to your web api but is giving error.
Below the line where I pass the values ​​pro web api:
string listaParcelaSeparadoVirgula = null;
foreach (var item in listaParcelas)
{
listaParcelaSeparadoVirgula = listaParcelaSeparadoVirgula + ";;" + item;
}
var result = HttpUtility.UrlEncode(listaParcelaSeparadoVirgula);
var response = client.PostAsJsonAsync("api/LancamentoReceitaDespesa/AddLancamentoParcelar/" + result, lancamentoReceitaDespesa).Result;
the result is a string variable with values ​​separated by ";;". Below the contents of the string:
";;aaaaa 1/2||10/01/2014|100,00||;;aaaaa 2/2||10/02/2014|100,00||"
with UrlEncode:
"%3b%3baaaaa+1%2f2%7c%7c10%2f01%2f2014%7c100%2c00%7c%7c%3b%3baaaaa+2%2f2%7c%7c10%2f02%2f2014%7c100%2c00%7c%7c"
Error:
{"Error while copying content to a stream."}
How can I pass these values ​​pro web api?
Well you could try encode value with base64 since in url you could have special symbols
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(result);
var response = client.PostAsJsonAsync("api/LancamentoReceitaDespesa/AddLancamentoParcelar/" + System.Convert.ToBase64String(plainTextBytes), lancamentoReceitaDespesa).Result;
then in web
public void AddLancamentoParcelar(string base64EncodedData) {
var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData);
var result = System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
}
I am not sure if its the best solution but as you could have any symbol in url then its could be an solution.