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

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.

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)
}

Sending sms to multiple phonenumbers using mysms 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.

How to Set with Priority in Angularfire

I'm having trouble understanding how to set with $priority in angularfire. I am trying to add a username with the key as username.
For example if I try:
var object = {user : "name",
$priority : "this"};
var ref = new Firebase(FIREBASE_URL + 'users');
var newBar = $firebase(ref);
newBar.$set(username, object);
The firebase set fails because of the invalid character "$" in priority.
I understand that instead I could try :
var object = {user : "name",
$priority : "this"};
var ref = new Firebase(FIREBASE_URL + 'users');
var newBar = $firebase(ref).$asArray();
newBar.$add(object);
This succeeds in adding the object to the array, but doesn't give me the opportunity to set the key to username as I require.
I can't think of any other way to achieve this currently. Is there any way to use set that allows me to set $priority? Or any alternative method to achieve the same?
Thanks
$priority is a property that exists on synchronized objects and records inside a synchronized array. As you've noted, it's not an allowed key in firebase data, so using it with $firebase::$set doesn't make sense here (since $set takes a valid json object which is stored directly into Firebase). Reading the API specifications can be a big help here.
There is also no need to create a synchronized binding for this use case. Just use the existing Firebase reference:
var ref = new Firebase(URL);
ref.child(username).set(object, function(error){ /* ... */ });
If there is some use case for working within a synchronized binding, then just use the Firebase meta property .priority:
var object = {user: "name", ".priority": "this"};
var ref = new Firebase(URL);
var sync = $firebase(ref);
sync.$set(object).then(/* ... */);
In case anyone else is looking at this, I have now taken the approach of using set first and then setting priority thereafter like this:
var object = {user : "name",
$priority : "this"};
var username = "user1";
var ref = new Firebase(FIREBASE_URL + 'users');
var newBar = $firebase(ref);
newBar.$set(username, object).then(function(){
var ref2 = new Firebase(FIREBASE_URL + 'users/' + username);
var newBar2 = $firebase(ref2).$asObject();
newBar2.$loaded().then(function(){
newBar2.$priority = authUser.uid;
newBar2.$save();
});
});

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.

How can I rotate back?

I am developing a wcf service for Windows 8 APP. But I'm choked up at one point.
The following method, it is coming data in the database using entity. But this the data returns back to a class type. My question , if result is null what can I sent person who will this method
public AnketorDTO AnketorBul(string tc, string pass)
{
_entity = new AnketDBEntities();
var result = (from i in _entity.Anketors
where i.TC == tc
where i.Sifre == pass
select i).ToList();
if (!result.Any())
-->>> return new AnketorDTO();
Anketor anketor = result.First();
return Converter.ConvertAnketorToAnketorDTO(anketor);
}
with this methot I SENT it by creating a new class type but part which use this methot does not work because the values become null. how can we prevent it.
Client :
AnketorDTO anketor = await client.AnketorBulAsync(txtKullanici.Text, txtSifre.Password);
**if (anketor != null)
lblError.Text = anketor.Adi;**
else
lblError.Text = "Hata";
Can you try this method to see, if it works?
_entity = new AnketDBEntities();
var result = _entity.Anketors.FirstOrDefault(yourexpressions);