Node express post insert with return

npm install body-parser needed.

var bodyParser = require('body-parser')
app.use( bodyParser.json() ); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true
}));

app.post('/register', function (req, res) {

MongoClient.connect(url, function(err, db) {
if (err) throw err;
var dbo = db.db("fcparser");
var usr = { username: req.body.nick, email: req.body.email, password: req.body.password };

dbo.collection('users').insert(req.body, function (err, result) {
if (err)
res.send('Error');

else
res.send('true');

db.close();

});

});
})

Create and run a nodejs webserver

create a js file with the nameofyourfile.js and copy the code below

var http = require("http");

http.createServer(function (request, response) {

// Send the HTTP header
// HTTP Status: 200 : OK
// Content Type: text/plain
response.writeHead(200, {'Content-Type': 'text/plain'});

// Send the response body as "Hello World"
response.end('Hello World\n');
}).listen(8081);

// Console will print the message
console.log('Server running at http://your.server.ip:8081/');

On the console type

node nameofyourfile.js

PHP save picture from url and convert .gif to .png

$picname = 'avatar'.uniqid().uniqid();

$ch = curl_init("https:".$picture->src);
$fp = fopen('/var/www/html/Python/users_avatar/'.$picname.'.gif', 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);

imagepng(imagecreatefromstring(file_get_contents('/var/www/html/Python/users_avatar/'.$picname.'.gif')), '/var/www/html/topzapp/users_avatar/'.$picname.'.png');