Botnary / wp-slim-framework

Slim framework as Wordpress plugin
73 stars 26 forks source link

I'm getting the 404 but can't get an output #5

Closed dcp3450 closed 9 years ago

dcp3450 commented 9 years ago

I have the plugin installed in the correct spot, I've changed the settings for the plugin to nano/api/, and I'm using /%postname%/, for the permalinks. I'm running locally via MAMP. I created a test plugin to play with Slim:

add_action('slim_mapping',function(Slim\Slim $app){
    //here you have access to slim $app and can define routes
    $app->get('slim/api/books/:id',function($bookId)use($app){
    echo 'book';
});

I'm getting the Slim 404 when I pass localhost/nano/api/books/12. I'm hoping to get "book" back. The idea, once I get working is to return json. Right now I just want to return something with my get calls instead of getting the Slim 404 page (I know it's not the WP 404).

Botnary commented 9 years ago

does your implementation looks like this ?

add_action('slim_mapping',function($slim){
    $slim->get('/nano/api/books/:id',function($bookId){
            echo $bookId;            
    });
});

how is your wordpress installed ? in a sub folder ?

dcp3450 commented 9 years ago

Turns out it was the piece you pointed out. I figured it out right after I posted this. The instructions say, this:

add_action('slim_mapping',function($slim){
    $slim->get('/site/api/user/:u',function($user){
        printf("User is %s",$user);            
    });
});

but it doesn't say that if you change the default on the settings page you need to update the above code manually. That was my confusion.

Botnary commented 9 years ago

Is good it's working now :)