How to post HTTP request with Arduino + ESP8266 AT commands - arduino

In order to send data to google spreadsheet I need to request HTTP access to the unique URL, something like this:
https://script.google.com/macros/s/AKfycbz7jkkd7nfa6ThjOqGw5KZgnUUxIOrxCV_m8WithLQD4EAS7hx6/exec?SOMEDATEHERE
I tried with:
GET https://script.google.com/macros/s/AKfycbz7jkkd7nfa6ThjOqGw5KZgnUUxIOrxCV_m8WithLQD4EAS7hx6/exec?SOMEDATEHERE HTTP/1.0,
but with no success.
Any idea how to execute this HTTP request with AT Commands?

I manage to do it.
First of all I wasn't able to make it work with Arduino IDE Serial Monitor because of Carriage Return and New Line characters so I switched to RealTerm. In it I manually write "\r\n" after every AT command. New i connected Googles Spreadsheet link with Pushingbox (as shown in this video). After that I used next AT commands:
// Only after Restarting module
//-----------------------------
AT+CIPMODE=0\r\n
AT+CIPMUX=1\r\n
//-----------------------------
AT+CIPSTART=4,"TCP","api.pushingbox.com",80\r\n
AT+CIPSEND=4,89\r\n
GET /pushingbox?devid=<DevID>&<field>=<value> HTTP/1.1\r\nHost: api.pushingbox.com\r\n\r\n
Thanks for help.

Related

How to get items from headers by learning from initiators and using request python?

I am trying to get the fingerprint as can be seen from this snapshot.
I tried searching for the fingerprint but it's not in the response or cookies. I am wondering how this fingerprintjs works so that I can imitate and return the fingerprint item.
The website is https://alfagift.id/
When you take a look into network, especially categories, there's a preflight and an xhr where it is initiated by https://alfagift.id/_nuxt/ca268e7.js
I've tried doing a requests
resp=requests.get(" https://alfagift.id/")
resp.cookies
nothing seems to be returning the fingerprint that's needed.
Can anyone show me how you can get the fingerprint?
This file's rendering and executing the fingerprinting script on the client side: https://alfagift.id/_nuxt/f9d159c.js
Proof:
__fpjs_d_m||Math.random()>=.001))try{var t=new XMLHttpRequest;t.open("get","https://m1.openfpcdn.io/fingerprintjs/v3.3.3/npm-monitoring",!0),t.send()}catch(t){console.error(t)}}(),[4,vt(r)];case 1:return t.sent(),[2,gt(L(ft,{debug:n},
Used library: https://github.com/fingerprintjs/fingerprintjs

Sending email attachment

I need to send a pdf file received from SFTP with an email as an attachment. I am just looking if this can be done without using custom pipeline component. Can this be done only with SMTP send port configuration. How can this be approached
In your orchestration your Out message must be modified like below. You must give your file list with pipe delimited list.
MessageOut(SMTP.Attachments) = "C:\\temp\atachment1.pdf|C:\\temp\atachment2.pdf";

Error occuring when trying to upload file via FTP using Qt

I have a file in my folder and I want to send it to my Embedded Linux device via FTP (much like this and this and this). I know the step-by-step to do it, but I'm failing when it comes to creating the correct QUrl for it: when I call ''put'', I always get the error 301:
QNetworkReply::ProtocolUnknownError 301 the Network Access API cannot honor the request because the protocol is not known
As details, I want to save the file in a specific directory located inside a SD Card in the device, /media/mmcblk0p2/bin, and the connection doesn't have, at least for now, a password and user name defined¹. Also interesting to notice that I'm not being able to connect myself via FTP using Terminal; it always says "421 Service not available, remote server has closed connection", which is not the same problem AFAIK. (Btw I'm being able to connect via SSH using FileZilla, so it's not a hardware/physical problem)
So where is the problem? I have exactly the same code as in the mentioned links. As for now, the link I'm using is
ftp://10.1.25.10/media/mmcblk0p2/bin/center.png
(when returning the QUrl object with QDebug) and I'm not being able to make it work.
Any help would be appreciated.
¹: Btw I remember reading somewhere that when one doesn't use a user name for connecting to FTP, the system only allows the client to connect to the /ftp folder. Is that true? In that case, just calling QUrl::setUserName("root"); would suffice?
I finally discovered my problem: since I was copying the code from examples of upload to HTTP servers, I was using the function "post", specific for HTTP, instead of "put" which was the correct function to use.
Regarding the QUrl, I used QUrl urlTemp("//10.1.25.10/test.info"); while telling it to use ftp with scheme, urlTemp.setScheme("ftp");.

How can I configure apache to send an email on every HTTP error 500

I have some server applications running on apache2; Ruby on Rails, PHP and others.
In all cases I would like apache to send me an email whenever apache responds a HTTP error 500 Internal server error.
How can I do that?
One way you can do this is use a php script that sends email, as well as output some sort of 500 message. Then use the ErrorDocument directive:
ErrorDocument 500 /path/to/script/that/sends/email.php
It is not possible to configure apache to send emails.
There are some things you can do to achieve the same result:
You can use the ErrorDocument directive to let it point to some CGI
script, that be a perl, PHP, or any other server-side executed
script. The script can then send an email and respond a Error 500
document.
You can use some external tool to watch your apache log
files and configure theese tools to send you emails. There are several tools and ways to do this. For Linux many
tools and methods are suggested on
https://serverfault.com/questions/45246/linux-monitor-logs-and-email-alerts
Write an apache module. I think that mod_tee is a good starting point.
Create a script called log_monitor.sh:
#!/usr/bin/perl -w
use strict;
my $cachefile="/var/cache/lastpos-apache2-scan4maxclntOrSigKill";
my $logfile="/var/log/httpd/error_log";
my $searchstr=" 500 ";
my $lastpos=0;
if (-f $cachefile) {
open FH,"<".$cachefile;
$lastpos=<FH>;
close FH;
};
my $newpos=(stat $logfile)[7];
open FH,"<".$logfile;
seek FH,$lastpos,0;
while (<FH>) {
print if m/$searchstr/i;
};
close FH;
open FH,">".$cachefile;
print FH $newpos;
close FH;
modify $searchstr as needed. note the spaces around "500", since you don't want to match errors which contain a 404 on a file that has "500" in its path or filename (among other places).
configure the script to run every X minutes via cron. the greater the value of X, the less emails you will get (only 1 email every X minutes for all the errors that match the strings you supply). the results of the cron job will get emailed to you automatically (if cron is setup properly)

Could it be that the google url shortening api key works only on 1 computer?

I'm using the Google URL Shortener from an ASP.NET website. It works
fine from my localhost, but on the test server I get the following
error:
System.Net.WebException: The remote server returned an error: (403)
Forbidden.
at System.Net.HttpWebRequest.GetResponse()
at GoogleUrlShortnerApi.Shorten(String url)
I'm using the exact code that is shown here:
http://www.jphellemons.nl/post/Google-URL-shortener-API-%28googl%29-C-sharp-class-C.aspx
Could it be that the key works only on my local computer, and not any other computer? I have obtained another key (using another Google account), but this one gives me the same error (403) both on my local computer, and on the test server.
I doubt very much the API is linked to a particular PC. You need to check the requests - both the URL and headers - that your program is sending out, they must be different in some way. Is your server behind some kind of proxy - e.g Apache? If not configured right this might also be mangling the request. Also make sure your requests are encoded correctly.
I made a few modifications, according to a tutorial by Scott Mitchell, and I change the following lines of code:
First, Instead of:
string post = "{\"longUrl\": \"" + url + "\"}";
I used:
string post = string.Format(#"{{""longUrl"": ""{0}""}}", url );
Second, I commented out these 2 lines:
request.ServicePoint.Expect100Continue = false;
request.Headers.Add("Cache-Control", "no-cache");
I don't know why, but suddenly it started working. So I wanted to see which of the 3 thins I did made the problem, so I returned each one, and - TADA - it still works, even with all 3 back there! So I really don't know what caused the problem, but since the code work without those 2 commented out lines, and the other modification, I am leaving it that way.
I hope this answer will help someone sometime...

Resources