Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 377
  • Last Modified:

HTTPS Post API

We have several devices in the "field" that upload data to our FTP server and we ingest the data from there. We are looking to try more of an "API" route and have our embedded C and linux devices use HTTPS posts to send the data up.

https://ingest.api.example.com

Then have our devices send data via json? xml? ??

and have a PHP script ingest the data into our database.

So connect to https://ingest.api.example.com

Send :
Field Unit Type: X1
Data1: 100
Data2: 5

So my question is, are we walking down the right path for a secure way to upload to our servers. Second, any example code or preference between json or xml?
0
-TNT-
Asked:
-TNT-
  • 2
  • 2
  • 2
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
POST uses name/value pairs to send data to a server.  Typically it looks like this and PHP will decode it as separate named $_POST values.
FieldUnitType=X1,Data1=100,Data2=5

Open in new window

PHP using curl will work on the Linux machines but I don't know what you need in C.  You will probably need to connect to the OpenSSL library to make and support the HTTPS connection.
0
 
Ray PaseurCommented:
What is the true URL of this API?  The posted URL does not work.
0
 
-TNT-Author Commented:
Thanks, this is is direction we have been headed. I just wanted to hear somebody else say it. Would you run the ingest script as a CGI?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
-TNT-Author Commented:
Hahaha... example.com doesn't work???? hahha

Read the post, we have no API, working on it now.
0
 
Dave BaldwinFixer of ProblemsCommented:
No, the 'ingest' script would just be a PHP page, it doesn't 'require' a CGI directory like you would use with Perl.  It would run with the interface used by the web server.  The older interface was called ISAPI but most sites use FastCGI these days.  However, it's not something that you have to be concerned about unless you are setting up PHP yourself.  Even then, it's just a choice between ISAPI and FastCGI.  On this computer with PHP 5.3.28, all I see is 'php-cgi.exe' and no 'php5isapi.dll'.
0
 
Ray PaseurCommented:
Hahaha... example.com doesn't work???? hahha
That's right.  If you want to get help at EE (or in any other forum) posting a bogus URL is a non-starter, and you would be amazed how often people do this.  Please take a moment to learn about the SSCCE, and use that strategy in formulating your questions.  If you don't have an API yet, just write a simple script that bounces the request variables back to the requesting client.

On the question of XML vs JSON, choose JSON.  It's got a better payload-to-propellant ratio and it's easily consumed by many programming languages.
http://json.org/
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now