CodeIgniter Forums
POSTing to CodeIgniter API - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: POSTing to CodeIgniter API (/showthread.php?tid=68707)



POSTing to CodeIgniter API - Simon_Startup - 08-15-2017

Hey Guys,

I'm working with a codeigniter website with API and for some reason I am unable to get server-side content from POST requests. 

Here is some code samples of the API. Everything works fine when POSTing from the website to the server, but via a service like POSTman I cannot seem to view data as I normally would aka $this->input->post('my_field') 

https://gist.github.com/simistern/6af216e56f5fdb18e6951e81dd050745
https://gist.github.com/simistern/063d3e1460723f36f74676101ee33781



Any help would be greatly appreciated!


RE: POSTing to CodeIgniter API - jarmen_kell - 08-15-2017

judging from the way you code your PHP script,
you're doing it wrong.

you couldn't just catch a value from a function that doesn't have any 'return' words.
and the way you put your 'return' r-word from the index clearly indicates that you
needs to understand the way how a simple 'functional' (or a little OOP) works.

here's a resource that might help on understanding how function works.
https://www.kidscodecs.com/programming-functions/

and here's also a little insight about how OOP works in PHP.
probably not the best tutorial, but it should do:
https://www.tutorialspoint.com/php/php_object_oriented.htm