Posted on 2014-07-17
Last Modified: 2014-07-19
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.

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

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

So connect to

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?
Question by:-TNT-
    LVL 82

    Accepted Solution

    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.

    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.
    LVL 107

    Expert Comment

    by:Ray Paseur
    What is the true URL of this API?  The posted URL does not work.

    Author Closing Comment

    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?

    Author Comment

    Hahaha... doesn't work???? hahha

    Read the post, we have no API, working on it now.
    LVL 82

    Expert Comment

    by:Dave Baldwin
    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'.
    LVL 107

    Expert Comment

    by:Ray Paseur
    Hahaha... 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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    PHP Radio Array 4 27
    code igniter select query 7 21
    Post a good COM tutorial 1 20
    generate a dynamic mysql query 2 23
    Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
    SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now