I am writing a trigger, in which i need to invoke the external application using the MySQL
Looking a your comment, the response is obvious.
Write a program in whichever language you dominate the best. That program needs to
Read all email addresses
Iterate on the list
Send a mail in every iteration
If you promise not to use it for sending spam, I can give you a basic PHP script to do that
I would suggest having the external application request the list of users, and then looping through the list and sending the email. There's no real reason to mix the two.
Related
I wrote an bot on GAS to read from / write to a google sheet from telegram. I use the webhook method. I can address the bot with /read <args> and /write <args>. However, the less tech-savvy are not able to understand the principle of arguments...
So I want to make a conversational bot, like botfather. eg, if /read or /write are sent, then the bot ask in pm for the arguments, one by one.
The "reply in PM" part is easy, but I don't see how I can catch replies for arguments?
As far as I understand, the function doPost is called each time a command is sent to the bot which poses issues of interactivity, and requiring a slash-something command to run the script instead of a plain text reply (and as the GAS data is volatile, the ugly work-around of storing a variable to know the bot should do the 2nd action is impossible too).
Is it feasible with webhook method?
Should I switch to polling / getUpdates method? I'm guessing it could work that way, with a time-out to exit the script in case of no reply, but I'm also guessing the PM chat should be set to 'no privacy' mode. or maybe it is intrinsic to the bot?
Any help appreciated!
So, GAS does offer a not-so volatile storage: CacheService.getScriptCache() (see also https://developers.google.com/apps-script/reference/cache/cache)
The principle is simple: store the variable you want persistent in the cache (optionally, set a time out too - the default is 10min), and get the values when the script is called again. I found out that project that helped me understand how to use it: https://github.com/Milleus/tessara/blob/master/Code.gs
In a few words: the syntax is cache.put(key, value) to store the value, and value=cache.get(key) to fetch it back.
The beauty of it is that all required variables (if more than one) can be stored in an object, the key can be a unique identifier for the "user", and the value is the stringified object.
In my case, I was able to build a fully conversational telegram bot (exactly like BotFather, but for my usage). Using the id from the person sending messages to the bot as the key, the script can run in "parallel" for multiple users at once.
The doGet and doPost are the functions that get called when you follow a web app url. You can use them as an api if you use something like UrlFetchApp to access them or even an Http Request if you can handle the oauth.
I made an online store coded in JSP and tables stored in MysQl. I'm using servlet and classes. I would like to get notify by mail at admin#domain.com when an order is inserted in the database.
Likewise, the customer should receive the order confirmation to the email they entered when they submit the form.
I would like to get feedback on how to do such a task. What's the best practice? I hope to not get back fire with this question because I`m aware there are several answers possible.
Basically, I`m just looking for the easiest and fastest implementation without too much hassle!
The form contains very sensitive and confidential data like address and such. But, since our customers can track their orders on the site, the data should not be sent, for security purposes. Just a message to confirm the reception of their order.
Please guide me in the right direction.
If you are using Hibernate i would recommend you using an entity listener, specially with a #PostPersist callback. You can read about it in Chapter 6. Entity listeners and Callback methods.
The email part can be done using the JavaMail API.
You can check an example of sending an email in Sending an Email using the JavaMail API.
Hope it helps!
I'm trying to figure out how to insert/update data into offsite databases that don't have an API available. Since they don't have an API, I thought of an approach I can take to insert/update data into their database.
They would first need to build a script and place it in an accessible location on their webserver that I can access via a URL. They would be required to supply the URL to me. I then can do a cURL POST request to that URL and pass a JSON array of the data that needs to be inserted. The script on their server would handle the parsing of the JSON array and the insert/update into the database.
I think this should work, but what security issues would I be opening them up to?
What you described is them creating an API. Just because the url invokes a script and isn't written in something like Java or PhP doesn't mean its not an api.
You need to make sure your url is secure so only authorized people can invoke it, and they would probably want to do data validation.
You should let them decide whether that is easier than standing up a more robust/non-script based solution
Is it possible to use email to update mysql table?
for example I have someone send email which have today article with the image as an attachment and it have to send to particular email address (eg: abc#something.org) to be able to process data to sql table, other address will not work for updating.
Once it receive, it automatically proceed and update sql from the article it receive.
How is it work?
is there any open source that may help this process
Not by sql, you have to involve some sort of programming language which have a subset of methods to communicate with the database and that can receive and send email.
Take a look at Sendgrid (at http://sendgrid.com): they have a parse API (see http://wiki.sendgrid.com/doku.php?id=parse_api for details) that basically lets you convert an email into an HTTP POST. So if you already have a web page that can update the MySQL database you can just modify it to comply with their spec, set up a sub domain that forwards to Sendgrid and then setup a Sendgrid endpoint that takes any email to that sub domain and posts it to your web page.
It depends on your application. If you're using a framework like Wordpress, there are plenty of plugins available to integrate (e.g. Postie). If you have your own custom application, you may find an open source script to download the new messages, but you'll have to implement your own code to update your database.
I'm trying to develop a test framework for some ActionScript code we're developing (Flex 3.5). What's happening is this:
As part of a Web Analytics function we are calling a track method in a class, providing the relevant information as part of the call. This method is provided in a library (SWC), and we have no access to the code.
Ultimately the track method sends an outgoing http request to the tracking server. We can see this quite happily in HttpFox.
I was hoping to be able to capture this outgoing request and interrogate it in my test class, allowing us to a) run tests in a more standalone fashion, and b) programmatically determine that the correct information is being tracked.
No problem just run this developer tool that displays all requests leaving your machine.
http://www.charlesproxy.com/
Unless you're going to use a sniffing tool, which probably would be hard to use for a programmatic evaluation, I would recommend using a proxy to channel your request. You could let the track method send the request to a php script on the proxy server, have it evaluate the request content, and then forward it to the actual tracking server. I suppose on a tracking system, you won't need to worry about the response, so it shouldn't be too hard to implement.
You could run a web server on a localhost (or any really) and just make sure the DNS entry the code is trying to access points to the server you are running.