How to Get Response String from HTTP Server using HTTPSRedirect.h (NodeMCU) - arduino-uno

The following code is responible for getting a string from HTTP Server
while (client.connected())
{
if (client.available())
{
String line = client.printRedir(url3, host);
Serial.println(line);
}
}`
Error Message:
no matching function for call to 'HTTPSRedirect::printRedir(String&,
const char*&)
How to store the response string from server

The use of HTTPSRedirect library makes the task much simpler by avoiding the need of any third party service. So, the first thing you need to do is to copy the HTTPSRedirect library files from GitHub and install into your Arduino libraries folder. I have also posted the zipped library files at the following link for convenience.
Download HTTPSRedirect Library
Update: The above library is outdated.
Please go to GitHub Sujay Phadke and download the updated library. Thanks Sujay.
from above discussion it must be you are using old version of HTTPSRedirect library,
to get new got to [Updated Library ] and download the library and copy the HTTPSRedirect folder from zip folder into the Arduino Ide libraries.
the above process solved my issue.

Define the host as below
const char* host = "your host";
And for string use
String url = "your complete url";

Related

NodeJS: protoc generated files not generating service definition

Have a relatively simple helloworld.proto file down below
syntax = "proto3";
package helloworld;
service Greeter { rpc SayHello(HelloRequest) returns (HelloResponse); }
message HelloRequest { string name = 1; }
message HelloResponse { string message = 1; }
When I run protoc --js_out=import_style=commonjs,binary:. .\helloworld.proto it generates a helloworld_pb.js file but it doesn't include my Greeter service nor my SayHello rpc function. Looked around a few other post and also Google's reference (https://developers.google.com/protocol-buffers/docs/reference/overview) and it seems like I need to include a --plugin option but I can't seem to find any. Does anybody have a solution to for this?
The protoc plugin for Node gRPC is distributed in the grpc-tools npm package. That package provides a tool grpc_tools_node_protoc that is a version of protoc that automatically includes the plugin.
As described in that package's README, when you run the tool you will also need to use the --grpc_out argument to control the plugin. The question is tagged grpc-js, so you will probably want to use the grpc_js option for that argument to generate code that interacts with grpc-js.
For those that have been looking for an example that also generates typescript see below
grpc_tools_node_protoc.cmd --js_out=import_style=commonjs,binary:.\output --grpc_out=generate_package_definition:.\output *.proto
grpc_tools_node_protoc.cmd --plugin=protoc-gen-ts.cmd=./node_modules/.bin/protoc-gen-ts --ts_out=.\typescript -I .\output *.proto

PhoneGap Build API for Node.js - Unable to load a custom build

I am trying to upload a zip file containing my App into PhoneGap Build by using the API with Node.js but it doesn't work, it does if I upload the file manually from the website.
After a successfully authentication with this piece of code:
pgBuild.auth({ token: phonegapBuildToken }, authenticationResponse);
in my callback I do the following:
function authenticationResponse(e, api){
unlockAndroidKeyMethod(api);
unlockiOSKeyMethod(api);
var options = {
form: {
data: {
platforms: ['android', 'ios']
},
file: './www/xxx.zip'
}
};
api.post(phonegapEndpoint + '/build', options, function(ee, data) {
console.log('## BUILD IN PROGRESS...');
console.log(ee);
console.log(data);
//waitingForPendingBuild(api);
});
}
inside the option I am pointing to the file I want to load
file: './www/xxx.zip'
the problem is that whatever I put there it doesn't get picked up, what PhoneGap Build builds is the file always the file loaded through the website.
Can I get some help, please? :)
Thanks
PS: I get no error
I have managed to solved this problem - it was a problem on how I create the zip file apparently...PhoneGap Build API don't like zip files done with gulp-zip, using archiverjs (https://archiverjs.com/docs/) solves the issue :)
Thanks

VLC Lua scripting https request

I'm writing a small vlc extension for nba league pass, actually i rewrite kodi addon for vlc, and i'm stuck at very beginning with LogIn function, i write working lua script in ZeroBrain Studio
http = require("socket.http")
json = require("dkjson")
ltn12 = require("ltn12")
https = require("ssl/https")
data = "username=user&password=pass"
res, code, response_headers, status = https.request {
response_body = {} ,
method = "POST",
headers= {
["Content-Type"]="application/x-www-form-urlencoded",
["Content-Length"] = data:len()
},
url = 'https://watch.nba.com/nba/secure/login?',
source = ltn12.source.string(data),
sink = ltn12.sink.table(response_body)
}
print (response_headers["set-cookie"])
Problem is that it uses "https". I've tried do this but get error
Error while running script C:\Program Files (x86)\VideoLAN\VLC\lua\extensions\nba_league_pass.lua, function (null)(): error loading module 'socket.core' from file '.\socket\core.dll': dynamic libraries not enabled; check your Lua installation
So, my question is how to make https request in vlc?
Thanks.
error loading module 'socket.core' from file '.\socket\core.dll': dynamic libraries not enabled; check your Lua installation
"dynamic libraries not enabled" usually indicates that your Lua interpreter is compiled without LUA_DL_DLL compilation flag (on Windows); specifying this compilation flag enables loading of dynamic libraries. (The Lua interpreter would be the one packaged with or embedded into VLC if that's what you are running.)

File Write - Unauthorized Access Exception

Trying to save a file locally from an app running in the iOS 8 Simulator and I'm continually getting access denied exceptions.
In previous apps I've used the following code to get a valid file path:
Environment.GetFolderPath(Environment.SpecialFolder.Personal)
or
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
But I've read that with iOS 8 this has now got to be written as:
NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.DocumentDirectory,
NSSearchPathDomain.User)[0]
So I'm using the following code to generate a file path for a .txt file and receiving an access denied exception when trying to save with it:
public void SaveMyFile(string content)
{
NSUrl[] urls;
string filePath;
//
urls = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.DocumentDirectory,
NSSearchPathDomain.User);
filePath = Path.Combine(urls[0].Path, "MyApp", "myFile.txt");
File.WriteAllText(filePath, content);
}
So the file path that it gives me and also denies access to is /Users/Idox/Library/Developer/CoreSimulator/Devices/92498E38-7D50-4081-8A64-83061DC00A86/data/Containers/Data/Application/C35B3E98-C9E3-4ABA-AA7F-CD8419FA0EA5/Documents/MyApp/myFile.txt.
I'm wondering if there's some setting that needs to be toggled to give the app write access to this directory or if the directory itself is invalid.
I've also done a call to Directory.Exists(string path) to check if the directory is there, which it is.
You're missing the Path property on urls[0].Path
filePath = Path.Combine(urls[0].Path, "MyApp", "myFile.txt");
This was fixed in Xamarin.iOS 8.4, so if you're using a recent version of Xamarin you can use Environment.GetFolderPath without problems (which is useful if you want to share code across platforms).

Get GraphicsMagick to open file from a https url?

I can use GraphicsMagick to download images given a URL, however when the URL starts with a https I get the following error (for https://example.com/image.png):
Unable to open file (//example.com/image.png) [No such file or directory].
I am using the gm driver for node.js with code like so:
gm = require('gm');
gm(url).write(name);
but have also tried the gm directly from the command line with the same issue.
As stated already, it works fine for http URLS, can I get it to work for https?
GraphicsMagick uses the HTTP support from libxml2, which does not currently support HTTPS. Try using an external program like 'wget' or 'curl' (which use OpenSSL to support HTTPS) to retrieve the file. Then you can pass the returned file to GraphicsMagick.
As Bob said, HTTPS is still not supported BUT:
Using the https module you can create a buffer and input it directly into GraphicsMagick.
https.get('https://www.eff.org/files/https-everywhere2.jpg', function(response) {
gm(response, 'image.jpg')
.write('test.jpg', function(err) {
if (err) return handle(err);
console.log('Created an image from a Buffer!');
});
});

Resources