Web dev and programming discussions forums
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account
Forum archives

Failed route & parameter


Forwarding to index controller with parameters.
My controller looks like:

class Login extends Controller
{

public function __construct()
{
parent::__construct();
}

function index()
{
header("Location: index/e/1");
exit();
}
}

In /config/routes.php
$route['index/e/1'] = "index/e/1";

This generates a 404.
I'm trying mimic index.php?e=1

Two things.
#1 My route is obviously wrong
#2 How can the Index controller fish out e=1, if $_GET is not enabled. is there another way to do this? Using session maybe?

Does anyone know the answers to #1 & #2?

View original thread with replies
Tags: controller

url parameter: cannot pass url as parameter to codeigniter methods

Hello guys,
I got a situation where i have to pass url to a controller method from views

controller function - parse_xmlfeed ($url)

url- http://202.63.102.83:8080/chandler/atom/collection/a57dbcd0-189c-11df-9078-b679d0519d0a?ticket=e8d4e840


i am calling this method like this

http://localhost/codeigniter/parse_xmlfeed/url

the error iam getting is 404 error (file not found)
i hope u understood


error from Debugger: Failed to launch simulated application: Iphone Simulator failed to find process ID of com.yourcompany.Hello-world

Hi,
I am using the iphone simulator 3.1 with Xcode 3.1.4. When I installed the Iphone Simulator It worked extremely well. But aftre building 2 to 3 project it started giving me the error "error from Debugger: Failed to launch simulated application: Iphone Simulator failed to find process ID of com.yourcompany.Hello-world". I thought there might be the problem with the code but when checked thoroughly I found out this problem is with the simulator because the other project was also giving the same error. In the Xcode the projects were building without any error but when the code is build with simulator it was giving this error.
I reinstalled the Xcode and the simulator but still it was giving same error
Please help me out
Regards SACHIN


Re: Authentication failed signature check failed.

I'm using below code after using your suggestion. but code is not working. Can you please check below code and let me know where I'm not right
System.out.println("timeStamp Start...........");
PhotobucketAPI api = new PhotobucketAPI();
// api.setOauthConsumerKey(apiKey);
// api.setOauthConsumerSecret(apiSecret);
api.setOauthConsumerKey(ResourceBundle.getBundle("consumer").getString(apiKey));
api.setOauthConsumerSecret(ResourceBundle.getBundle("consumer").getString(apiSecret));
api.setSubdomain("api.photobucket.com");
api.setRequestPath("/ping");
api.setMethod("get");
try{
RESTfulResponse responseXML = api.execute();
System.out.println("responseXML ..........." + responseXML.getResponseString());
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
System.out.println("timeSt
amp End...........");




When using below 2 line getting expection.
api.setOauthConsumerKey(ResourceBundle.getBundle("consumer").getString(apiKey));
api.setOauthConsumerSecret(ResourceBundle.getBundle("consumer").getString(apiSecret));


timeStamp Start...........
java.util.MissingResourceException: Can't find bundle for base name consumer, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(Unknown Source)
at java.util.ResourceBundle.getBundleImpl(Unknown Source)
at java.util.ResourceBundle.getBundle(Unknown Source)
at com.gagabase.dao.jdbc.manager.PingTest.testPing(PingTest.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
timeStamp End...........

When using below 2 line getting expection.
api.setOauthConsumerKey(apiKey);
api.setOauthConsumerSecret(apiSecret);


timeStamp Start...........
2009-12-15 13:41:36,734 [main] WARN DefaultRequestDirector:992 - Authentication error: Unable to respond to any of these challenges: {oauth=WWW-Authenticate: OAuth realm="[api.photobucket.com];}
responseXML ...........<?xml version="1.0" encoding="UTF-8"?>
<response>
<status>Exception</status>
<message>Authentication failed signature check failed</message>
<code>7</code>
<format>xml</format>
<method>GET</method>
<timestamp>1260864693</timestamp>
</response>
<!-- den2api02 @ Tue, 15 Dec 2009 01:11:33 -0700 -->

timeStamp ...........1260864693
timeStamp End...........




Do i did anything wrong here. Please suggest me.

failed to open stream: HTTP request failed! HTTP/1.1 503 Service Unavailable

Hi,
I am trying to read the content of url.
when manually i put url in browser

link : http://www.mvnforum.com/mvnforum/vie...ber=pbmissions
it opens.

but using code
$homepage = file_get_contents('http://www.mvnforum.com/mvnforum/viewmember?member=pbmissions');
echo $homepage;

Warning: file_get_contents(http://www.mvnforum.com/mvnforum/vie...ber=pbmissions) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 503 Service Unavailable in C:\xampp\htdocs\test.php on line 2

What is problem ?
How to solve this?

KO3 route help

Note: even though your regex is "one or more digits", the fact that it is in parentheses makes it still optional. E.g. this would match:

admin/chapters/chapter//create

It sounds like you want one of the following:

admin/chapters/chapter/(<id>/<action>)  // id and action both required or optional
admin/chapters/chapter/(<id>/)(<action>) // either id/action or id or action or neither - more like yours but without the double /

Colin


KO3 route help

The first one probably won't work.

Things in paranthesis are optional. So (<id>(/<action)) means that you can leave both out, or you can just leave action out, or you can include both. You will also need to set defaults in order for this to work right.


KO3 route help

Ok i figured, both could be optional if the data types were distinct. Like one was an integer and the other a range of values inside of an array ,

e.g array('id' => '\d+','action' => '(create|update|delete)')

Thanks for the help :)


KO3 route help

Actually colin

admin/chapters/chapter/(<id>/)(<action>)

Would force you to have a trailing slash which isn't recommended for displaying pages.

bluehawk had it right, he just missed a slash out from the start.

admin/chapters/chapter(/<id>(/<action>))


KO3 вопрос по Route

Posted By: biakaveron

У меня вот такой универсальный роут для форума:

$route = Route::set('forum', '(<directory>)(/)(<controller>(<id>)(/<action>)(/page<page>))', array ( 'controller' => '[a-z]+', 'id' => '[0-9]+', 'page' => '[0-9]+', 'action' => '[pL]+', 'directory' => 'forum(/admin){0,1}' )) -> defaults(...);

Например:

forum/category1/editor
forum/post2/page3
forum/admin/category4/delete

Ох ты блин! =))) Не я, конечно, читал, что route очень гибкий, но что б настолько! Возьму на заметку =)))


KO3 вопрос по Route

Господа, помогите с затруднением...
Написал до дефолтного роута:

Route::set('admin', 'admin(/<controller>(/<action>(/<id>)))')
  ->defaults(array(
    'directory'  => 'admin',
    'controller' => 'home',
    'action'     => 'index',
  ));

В папке контроллеров создал папку admin, в ней контроллер home (Controller_Admin_Home).

По урлу localhost/index.php/admin - всё работает правильно. А если вот так:
По урлу localhost/index.php/admin/foo - ругается что нет Class controller_admin_foo does not exist...


KO2 like route support in KO3

I'm thinking of something along the lines of this:

Route::set('admin', 'admin/<controller>(/<var1>(/<var2>))', array('controller' => '[a-zA-Z_-]+'))
    ->defaults(array(
        'action' => 'admin',
    ));

The second segment of the URI would match the controller, while the action is always set to "admin". If var1 and var2 are not optional, remove the parentheses around them.


KO2 like route support in KO3

The following line is taken from the Pyro CMS source code

$route['admin/([a-zA-Z_-]+)/(:any)/(:any)'] = "$1/admin/$2/$3";

Is it possible to enulate that functionality with KO3 ?

What it does is re-arranges the route. The admin from the start of the request is moved to second position in the route.

Thanks


Optional Route

Ok I have a problem with the router config.
I have a controller with this.
function index($cat = 1,$pag = 0)
{
$this->template->titulo =.....etc...

I'm trying to do this.
when I visit
site.com/controller
show category = 1 and page = 0
when I visit site.com/controller/2
show category = 2 and page = 0
when i visit site.com/controller/2/2
show category = 2 and page = 2

AND
when I visite site.com/controller/2/2/1
order DESC 2/2/2 order ASC
etc but the problem is in the router
how can I configure "variable" routes
i have this.
$config['listado/([0-9]+)/([0-9]+)'] = 'listado/index/$1/$2';
but the problem is
when I use
site.com/listado/2/0
WORK FINE!
but if I put
site.com/listado/2
this fail
and now i'm trying to put a 3º rd dinamic "variable" passing with the url
how can I put this "dinamic" route in a configuration file? because the doc is no longer explicit with this case.
except use "regex" but i can't understand HOW!

NOTE: I discover if I put site.com/listado/index/1/2/3/4 etc... work FINE! how can I remove this INDEX???


Optional Route

Posted By: morpheus747

i have this, $config['listado/([0-9]+)/([0-9]+)'] = 'listado/index/$1/$2'; but the problem is when I use site.com/listado/2/0 it works fine. but if I put site.com/listado/2 this fails

That is because you need to make the second part optional. E.g.
$config['listado/([0-9]+)(?:/([0-9]+))?'] = 'listado/index/$1/$2';

Note that it's important that you include the / inside the optional segment so site.com/listado/2/ and site.com/listado/2 will both be valid.

I'm not sure I understand the request of your questions.


Route assembly

I've set up a route in my bootstrap as follows:
Code:

$indexRoute = new Zend_Controller_Router_Route(
        ':module/:controller/:id',
        array('action' => 'index'),
        array('id' => '\d+')
);
$router->addRoute('index', $indexRoute);

This means URLs of the form /module/controller/index/id/1 can be shortened to /module/controller/1

It routes URLs as expected but when i use the url() view helper to assemble a URL it always uses this index route instead of the default route, even when the supplied action is not 'index'. For example
Code:

echo $view->url(array('module'=>'editor','controller'=>'node','action'=>'edit','id'=>$node->id));
#gives /editor/node/1 instead of /editor/node/edit/id/1

Even supplying a route name of 'default' doesn't help and anyway, shouldn't the default route be the, um, default?

Why is url() always using my index route?

Route :slug value
Mar 4, 2010
Hi all, I'm having a problem with routing. route.yml settings: Send: url: /exp/send/:token param: { module: exp, action: Send } And my action.php file: public function executeSend(sfWebRequest $request){ …

Sitemap route
Feb 5, 2010
Hi. I have sitemap controller <?php class SitemapController extends Zend_Controller_Action { public function init() { $this->_helper->contextSwitch ->addActionContext('index', 'xml') ->initContext(); } public...

Problem with Route
Nov 12, 2009
Hello everyone I am following the book Beginning Zend Framework of Armando Padilla. The it is suggested to create an alternative route: $Router->addRoute("artistprofile", new Zend_Controller_Router_Route ( "artist/:artistname", array(...

Search Along a Route
Jan 29, 2010
Hi, Please let me know how to per form search Along a Route using Google Map API in my site.

retrieve a set of routes for a route
Feb 26, 2010
Hello Guys, I'm trying to recover through the object GDirections, all routes a route. In the group of version 2 of the api, I was informed that it would be possible only through the object DirectionsRequest. Does anyone have an example of how to...

Clearing Directions route
Nov 10, 2009
Hi there, I have been developing an application using API 3 for some time now, and have 1 last bit of functionality to achieve. I have no live webpage to post, however my question is highlevel in nature and API related Is there a way to "clear" a...

Re: Route Rewrite Problem
Dec 17, 2009
A few things: * Make sure your route names are unique. I see two each of the 'articles' and 'articlenew' routes. * Remember that the last route defined will be the tried first, so put the more specific routes after the more generic ones. * The keys...

Help with setting up custom route
Jan 26, 2010
Hi, I am trying to setup a custom router to create a "admin area" type of thing: I've started with: $frontController = Zend_Controller_Front::getInstance(); $router = $frontController->getRouter(); $router->addRoute( 'listTeachers', new...

Route HTTPS traffic to a different IP
Nov 25, 2009
Hi guys, My logic is giving way on this one and I find I understand less about DNS than I thought: Say I have a domain hosted on one server, and there is an existing application using the same domain over https (with existing cert) on another...

How to Handle images w/ a Route
Feb 7, 2010
I store all of my full size images at something like /img/photos/ filename_goes_here.jpg I would like to be able to add a route so that if I visit /img/photos/75x75_filename_goes_here.jpg it will be handled by my images controller. I've tried...