We've been using curl
through the command line since the beginning of this book, but this time, we are going to trigger a curl
statement using PHP.
1. Let's start by initializing a
curl
session, executing it, and then closing it. Openindex.php
in your text editor, and add the following code into the/signup POST
route:post('/signup', function($app) { $user = new stdClass; $user->type = 'user'; $user->name = $app->form('name'); $user->email = $app->form('email'); echo json_encode($user); $curl = curl_init(); // curl options curl_exec($curl); curl_close($curl); $app->set('message', 'Thanks for Signing Up ' . $app- >form('name') . '!'); $app->render('home'); });
2. Now, let's tell
curl
what to actually execute. We do this with anoptions
array. Add the following code between thecurl_init()
and thecurl_exec
statements:post('/signup', function($app) { $user = new stdClass; $user->name = $app->...