Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. $app->post('/users/create/:data', function ($data) use($app)
  2. {
  3. $app->response->status(201);
  4. echo "The user ".$data['name']." was added successfully";
  5. }
  6. );
  7.  
  8. $data = array(
  9. 'id' => 3,
  10. 'name' => 'Gree3a'
  11. );
  12. $url = "http://localhost/api/users/create/";
  13. $ic = curl_init();
  14.  
  15. //set options
  16. curl_setopt($ic, CURLOPT_URL, $url);
  17. curl_setopt($ic, CURLOPT_POST, true);
  18. curl_setopt($ic, CURLOPT_POSTFIELDS, $data);
  19. curl_setopt($ic, CURLOPT_RETURNTRANSFER, true);
  20.  
  21. //perform our request
  22. $result = curl_exec($ic);
  23. curl_close($ic);
  24.  
  25. echo $result;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement