calling CI's Controller from external script using curl |
[eluser]toopay[/eluser]
Did you post some data? why you includes this line Code: curl_setopt($curl_handle, CURLOPT_POST, 1); Code: // include $_POST array
[eluser]tulipneo[/eluser]
Hi Http error code 302 means "moved temporarily.in other words i have a feeling that its trying to access some thing and does not follow CI's style of calling with controller/class/method. Br Tulip
[eluser]tulipneo[/eluser]
Hi Thanks for ur reply. i removed the post statement ie Code: curl_setopt($curl_handle, CURLOPT_POST, 1); and still no luck. and now i see in apache log as bellow. Code: 127.0.0.1 - - [25/Apr/2011:18:13:11 +0530] "GET /KSMS/index.php/messages/setInBox HTTP/1.1" 302 - Br Tulip
[eluser]toopay[/eluser]
Did you put some redirect() inside 'setInBox' function? Show your 'message' controller.
[eluser]tulipneo[/eluser]
My controller is as bellow. Code: <?php inside the method i have put a log message and a test data to database to make sure that this is called. Br Tulip
[eluser]toopay[/eluser]
Code: if($this->session->userdata('loggedin')==NULL) redirect('login'); In addition, you could do the database stuff on your model, using CI DB class, rather than manual connection like that. Also, consider what i suggest before, to using an API!
[eluser]tulipneo[/eluser]
Hi I was doing that way because i was already loged in and trying in another window.it should work because if i directly place the link ie http://127.0.0.1/KSMS/index.php/messages/setInBox in browser it works fine but not through curl. anyway i commented that ie if($this->session->userdata('loggedin')==NULL) redirect('login'); and still it did not work. br tulip
[eluser]toopay[/eluser]
If you already login, then make a curl call within that app, it should be worked. But, if you called from another app, then it was another story. [quote author="tulipneo" date="1303754745"] anyway i commented that ie if($this->session->userdata('loggedin')==NULL) redirect('login'); [/quote] make sure you use 'GET' method instead 'POST'.
[eluser]tulipneo[/eluser]
Hi Yes i use GET see logs bellow: Code: 127.0.0.1 - - [25/Apr/2011:18:45:54 +0530] "GET /KSMS/index.php/messages/setInBox HTTP/1.1" 302 - br Tulip |
Welcome Guest, Not a member yet? Register Sign In |