calling CI's Controller from external script using curl - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: calling CI's Controller from external script using curl (/showthread.php?tid=40870) |
calling CI's Controller from external script using curl - El Forum - 04-21-2011 [eluser]tulipneo[/eluser] Hi List, Good Day. I have a simple problem for which i have been goggling and searching CI forum. i open my browser and access the links http://localhost:8080/project/index.php/messages/setInBox so here i m able to access controller's class method setInBox.thats fine now i have written an external script and trying to access this through curl but it does not work.the external script is as bellow. Code: <?php Any help or advice or pointer could help me. Br Tulip calling CI's Controller from external script using curl - El Forum - 04-21-2011 [eluser]tulipneo[/eluser] Hi I dont have still any reply. i observed in this thread http://ellislab.com/forums/viewthread/131867/ Code: $_curl = curl_init ( "http://test.com/index.php/test/example" ); the bellow woks fine as claimed by the member but why not in my case. some one pls help. Br Tulip calling CI's Controller from external script using curl - El Forum - 04-22-2011 [eluser]tulipneo[/eluser] Hi List, pls suggest. i m stuck. is this an invalid question to ask. pls advice. br Tulip calling CI's Controller from external script using curl - El Forum - 04-22-2011 [eluser]bubbafoley[/eluser] use the curl library. it'll make things easier. http://philsturgeon.co.uk/code/codeigniter-curl calling CI's Controller from external script using curl - El Forum - 04-22-2011 [eluser]danmontgomery[/eluser] We can't do anything with "does not work", you need to be specific, post error messages, what you've tried, etc calling CI's Controller from external script using curl - El Forum - 04-23-2011 [eluser]tulipneo[/eluser] Hi thanks for the reply. inside code igniter controller i have a class called message with method setInBox(). Code: public setinbox() i open browser and type http://localhost:8080/project/index.php/messages/setInBox and press enter and my method is called. now i try to do the same thing with curl() which does not work. i can not use CI's curl here bocz i m tring to access Ci's controller from outside the framework. br Tulip calling CI's Controller from external script using curl - El Forum - 04-23-2011 [eluser]toopay[/eluser] Have you try Proxy Library? calling CI's Controller from external script using curl - El Forum - 04-23-2011 [eluser]tulipneo[/eluser] Hi Thanks for ur reply. i think Proxy Library and codeigniter-curl are meant for making calls from CI framework to outside but my situation is that i want to make cals from outside environment to CI framework. Br Tulip calling CI's Controller from external script using curl - El Forum - 04-23-2011 [eluser]toopay[/eluser] Do you mean you want to : 1. Get HTTP response for some url(in this case, the url is pointing to a CI controller function)?....or 2. Uses the class object on some CI controller, from different domain/app? The first one is possible to do, but i doubt you can do the second! calling CI's Controller from external script using curl - El Forum - 04-23-2011 [eluser]tulipneo[/eluser] Hi thanks for ur reply again. my idea is very simple. i have a project in CI. my requirement is tht an out side script should be able to call my controller "message" and method "setinbox". in order to do that i open my browser and try localhost/index.php/message/setinbox and the method is called. i want make the same with curl. so what u have mentioned in step1 is what i need. my code is as bellow <?php $url = "http://localhost:8080/project/index.php/messages/setInBox"; $ch = curl_init($url); $result = curl_exec($ch); curl_close ($ch); ?> so the above external code is trying to call method "setInBox" of controller "message" to my project in CI framework. now i see the method is not called. i can confirm that bcoz in first case the log is printed whats given in method name and second case no logs. br Tulip |