Send post data from HTML form to RESTful service using codeigniter - codeigniter

i've just learn about Restful service using codeigniter and created a form, when i submit, i want to send the data to restful service. This is the part of code :
<?php echo form_open_multipart('/mycontroller/myresource', 'class="form-horizontal"', 'role="form"'); ?>
is right if my action target URL resource like code above? if not, can u tell me how to send post data without target my url resource? i'm confused...

Related

Codeigniter: Redirecting from one view to another without going through controller class

I am making a OAuth request to Google Contact API and want to redirect response to another page.
Is it possible without going through Controller? (I understand it will be against MVC model)
If yes then what will be my complete redirect url for another page which is in View folder. Because I have to provide it upfront on Google API Console.
What code have you tried? What data will be displayed on the view. If there's no data it will be easy.

how to get user specified data with Asp.net Web API

I created MVC4 application with internet application template, added an API controller with authorize attribute.
How can I make api controller action return user specified data?
Currently I am using WebSecurity.GetUserID to get Userid, I have Userid in the data table.
After compiling the application, if I call api controller action first, I will have following error message:
You must call the "WebSecurity.InitializeDatabaseConnection" method before you call any other method of the "WebSecurity" class. This call
should be placed in an _AppStart.cshtml file in the root of your
site.
if I go to MVC controller action frist, and come to api action again, it works fine.
I am wondering how to solve this issue, and what is the best practice to handle user specified data with web api and MVC4, Thanks.

Post Form data to different Domain in MVC application

I have tried to post Form data from my mvc site to Other domain without page refresh[Ajax.post]. But the form data not saved in other domain.While I am posting same data to normal form post:`This data saved into Marketo site.
Can you suggest if there is any possible way to post the form data to cross domain without page refresh?
First Name:
Email Address:
Subscription
I have tried to post Form data from my mvc site to Other domain without page refresh[Ajax.post]. but the form data not saved in other domain.
That is because of the Cross Origin Resource Sharing (CORS) restriction
and to circumvent the CORS one of the possible solution is to make a proxy on your server side and have that proxy talk to the other domain that i thin what you mean by "while i am posting same data to normal form post[]. this data saved into Marketo site."
Can you suggest if there is any possible way to post the form data to cross domain without page refresh?
JSONP
[Cross-domain Ajax -- brief introduction]
What is JSONP all about?

ASP.NET MVC request forwarder

I would like to achieve this kind of functionality:
When a client makes GET request to
GET http://www.myserviceurl.com/rest/facebook/profile/me
to get response from
GET http://graph.facebook.com/profile/me
Application logic will append all nessesary parameters so the final url will look like:
graph.facebook.com/profile/me?access_token=XXX
Similar,
POST myserviceurl.com/rest/twitter/statuses/update.json
with post data
status=Maybe%20he%27ll%20finally%20find%20his%20keys.%20%23peterfalk&trim_user=true&include_entities=true
->
POST api.twitter.com/1/statuses/update.json
with POST data
status=Maybe%20he%27ll%20finally%20find%20his%20keys.%20%23peterfalk&trim_user=true&include_entities=true
This way I want to create a layer of apstraction and allow my clients to invoke my rest service using the same structure of provider rest url.
What will be a recommended approach?
Maybe You could use Facebook C# SDK (which is basically a wrapper for Facebook Graph API) to fetch json data from Facebook and return it to Your users.

How to do verify domain in RESTFul with ASP.NET MVC 3?

Currently, I building my website personal (using ASP.NET MVC 3).
I want to provide some services to public by using API, finished building everything, but RESTFul does not contain on Authorization, I read this article:
http://blogs.msdn.com/b/rjacobs/archive/2010/06/14/how-to-do-api-key-verification-for-rest-services-in-net-4.aspx
But I could not use the method with ASP.NET MVC 3!!
I want the following:
1- Send Api-Keys for those who want to use my service
2- verify Domain (owner api-key == OR != owner domain) !!!! Is this possible?
You could make it a requirement that they always send their key in the requests. Then you could subclass the AuthorizeAttribute to check if the key in the request matches something in your datastore. This attribute can then be decorated on your controllers.
You can get the domain making the request using Request.UrlReferrer

Resources