Support forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_TopicIcon
Complex SMS replies from the data base using http php request
sp_NewTopic Add Topic
December 10, 2024
9:38 am
Henk Helmantel
Admin
Forum Posts: 1562
Member Since:
May 28, 2013
sp_UserOfflineSmall Offline

Hello Yoyo,

You can use the 'Compile' button in the scripting editor of the Scripting Connector to check for syntax errors in the script.

In this script it shows an error with the $ character before the strings. This is because the scripting engine in Diafaan SMS Server uses an older version of C# that does not support interpolated strings. You will have use an alternative way to create the 'replyMessage' string, for instance with the 'String.Format' method.

Regards, Henk

December 10, 2024
4:05 am
YOYO
Guest
Guests

I used the following code but its not working
private void OnMessageReceived(string fromAddress,
string toAddress,
string message,
string messageType,
string messageId,
string smsc,
string pdu,
string gateway,
DateTime sendTime,
DateTime receiveTime)
{
// Get current date and time
DateTime currentDateTime = DateTime.Now;

// Example database query (pseudo-code, replace with actual query logic)
string queryResult = QueryDatabase(message);

// Example HTTP request (pseudo-code, replace with actual HTTP request logic)
string httpResponse = MakeHttpRequest("http://example.com/api", message);

// Compose the reply message
string replyMessage = $"Thank you for your message received at {receiveTime}. " +
$"Query Result: {queryResult}. " +
$"API Response: {httpResponse}.";

// Send reply message
PostSendMessage(fromAddress, "", replyMessage, "", "", "", "", 0);
}

// Pseudo-function to demonstrate database query
private string QueryDatabase(string message)
{
// Implement your database query logic here
return "Example Database Result";
}

// Pseudo-function to demonstrate HTTP request
private string MakeHttpRequest(string url, string message)
{
// Implement your HTTP request logic here
return "Example HTTP Response";
}

Please help me?

Forum Timezone: Europe/Amsterdam
Most Users Ever Online: 820
Currently Online:
Guest(s) 7
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Member Stats:
Guest Posters: 698
Members: 0
Moderators: 0
Admins: 1
Forum Stats:
Groups: 2
Forums: 3
Topics: 1189
Posts: 4057
Newest Members:
, Henk Helmantel
Administrators: Henk Helmantel: 1562