I am trying to create a index.phtml page to my RESTful Apigility API. Steps i have taken is
1) Create a DB connected API any given it route "account"
2) Access the account API on /account with postman and got HAL and JSON to response to work
3) Create a new "Selector" under content negotiation with 3 view models. "ZF\ContentNegotiation\ViewModel", "ZF\Hal\View\HalJsonModel" and "Zend\View\Model\ViewModel"
4) Selected the newly created selector in the accounts API
5) Created a index.phtml under Account/view/index.phtml with code "Test"
6) Added
'view_manager' => array(
'template_path_stack' => array(
'account' => __DIR__ . '/../view',
),
),
to module.config.php
7) Using postman and accessed /account with
Accept application/json // works
Accept text/html // don't work
Would be great if someone could lend a hand to get a index.phtml template to work with a restful DB connect API
If you want to use ViewModel you should choose RPC API. You can create RPC API with following this documentation
https://apigility.org/documentation/intro/getting-started#create-an-rpc-service
Related
I am using Restclient form my rails4 application and executing the post method for watch method of gmail,it needs topic and label as its parameter
This is my code
RestClient.post "https://www.googleapis.com/gmail/v1/users/#{email}/watch?access_token=#{token}", {"topicName" => "projects/project_name/topics/my_topic","label" => "INBOX" , "Content-type" => "application/json"}
its giving me bad request , can any one suggest me whats the right way ?
Make sure you have done this in proper order
Enabled pubsub in google developer console
Create topic
Create pubsub subscription
grant publish rights
I have an API endpoint that handles requests from a third-party app. The problem is that the 3rd-party application sends out a parameter named 'action', and in rails, params[:action] is equivalent to the action name of the API endpoint.
How do I retrieve the actual value of the 'action' parameter that was sent from the request?
The endpoint by the way is a POST method. I tried
request.POST['action']
and/or
request.request_parameters['action']
but the 'action' key is not present.
I am trying to perform different actions stored in the same controller using yii.
I have an action called "test" and I can access it by typing the url "localhost/blah/test", this url calls the method "actiontest()" in my controller, now what I want is by typing "localhost/blah/test/create" access the method "actioncreate()" which is in the same controller.
Is there any way to achieve that?
define in routes this rule in config:
'rules' => array(
'localhost/blah/test/create' => 'localhost/blah/create',
....
),
Is there a CakePHP method when requested a URL/link to be created (using a router array) that will respond with whether a matching pattern, and hence, friendly URL can be returned for the request?
Example: No routes matching array('controller' => 'thing', 'action' => 'show', 'abc' => 'def') will return the 'default' controller/action/params:values structure of /thing/show/abc:def.
I would like to know if a URL request was formed by a route. Otherwise the URL, and therefore the controller's action, should not be publicly accessible.
Note:
I have removed the require CAKE . 'Config' . DS . 'routes.php'; line from routes.php, so there should not be the 'default' matching of any controller/action, yet using the url method still returns the 'default' structured URL. It would be more convenient to use this result as a test for if a URL request is valid/publicly available.
I am aware that CakeRoute, which is used by Router, has the match() method which returns false on an unmatched URL after testing against all connected routes, but I can't figure out how to access this functionality from Router.
I am creating an application in zf2.
I have a Plugin (MyModule\Controller\Plugin\MyPlugin) that I can call in my controller without any problem.
I would like to be able to call it from a mapper (like it was possible in zf1 doing getStaticHelper().
I found that it is possible to get it in the view by doing Zend_Controller_Front::getInstance() and then call the plugin but this doesn't work in the mapper.
Is that possible?
Thanks!
I think you have to add to your module.config.php something like this:
'controller_plugins' => array(
'invokables' => array(
'userauthentication' => 'User\Controller\Plugin\UserAuthentication',
),
),
Then you should be able to call it from any controller:
$this->userAuthentication()->getAuthService()->hasIdentity();