Hello everyone. I am new to snap. and I need a real world sample on how to use the Snap API
to access and control maybe snap from the outside. I already try all whats in the API documentation but to no avail up until now. Its been 5 days I am working for this. Can anyone help for any sample on how to Implement Snap! API?
Snap! does not have cloud variables. If you need cloud variables, then you need to run your own server. If you want to save projects, there is an XML generator where you can replace the variable with another example. I found this from the Firefox network log, but even with chrome it is probably possible.
Maybe you already know it, but Snap! Api docs are here.
Aside this, maybe the main "problem" is how to implement this. I don't know if you are working on a web page, a server, a web service... This forum topic may be useful to you.
And if you don't need an online use, you also can use Snap4Arduino desktop edition. It has a webserver to connect http request directly to our Snap! world. Then, you can connect other webpages, other Snap! projects, other PCs from your network, mobile apps... Snap4Arduino http protocol docs here
Thank you so much Sir @jguille2 for the Snap4Arduino http protocol Link, but my question is so much related to @ericsteinpost
Is there any working sample of this API for me to start with?
That would be a great help for me.
What realy i am working on is a Snap Modification so that it can Access a Database using Blocks. I want Snap to be able to Read and Write a database by building a new Block that can Build Database Queries Like - "Select * From TableStudents" or
UPDATE table_name
SET column1 = value1 , column2 = value2 , ...
WHERE condition ;
This is what i come up so far:
I want to capture and execute the value of the abc varible from outside Snap. Can I do that using Snap API?
If you want to interact with a DB, I think you don't need any Snap! API, because you have an url block. What you need is "an API for your DB".
Mounting your DB with a WebServer you can build simple web files to make responses for web queries (and also, for Snap! queries).
An example... (using PHP):
<?php
//Your DB connection info
$servername = "localhost";
$username = "public";
$password = "public";
$dbname = "public";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = $_GET["query"];
$result = $conn->query($sql);
$conn->close();
// Returning data
while ($row = $result->fetch_assoc()) {
print_r($row);
}
?>