1

Integrating RESTFUL api in my application.

I've to use restful services in my new project. I'm using CakePHP 2.0.6

I do not want to create a restful services. I've to use restful services.

I want to know is there any ready made component is available in CakePhp to read restful services.

I want that component to serve me the output based on my services by doing the rest in the background. Additionaly if the component is able to log it then it will be well and good.

Vins
  • 8,849
  • 4
  • 33
  • 53

3 Answers3

0

A REST API is more a concept than a standard set of protocols, therefore there is no uniform way to interface with the APIs of different providers. Twitter has its own REST API, while Facebook provides another.

Most big webservices provide PHP classes to simplify interfacing with the API. For Twitter there's a third party library called TwitterOAuth and Facebook provides a PHP SDK. These can be loaded as Vendor files in CakePHP. See an earlier answer of mine regarding the loading of vendor files or this older post related to the 1.3 branch of Cake, but still relevant.

Several Cake developers have developed plugins for Cake to interact with popular webservices like the Facebook Plugin by webtechnick. Whereas loading vendor packages is the framework's equivalent of including them like you would in a plain PHP script, loading plugins is a bit different and might simplify things even more (or make them more abstract). The Cake manual entry on plugins has more information.

Community
  • 1
  • 1
mensch
  • 4,411
  • 3
  • 28
  • 49
0

I've found a PHP Class from http://www.phpclasses.org Which is looks like taking care of most of the REST API part, And it worked for me for my purposes. It has got nice example file which will demonstrate how to use that class.

I've converted this class into Cakephp component. Here is the URL to download the class. http://www.phpclasses.org/package/5480-PHP-Send-Web-services-requests-to-REST-servers.html

Vins
  • 8,849
  • 4
  • 33
  • 53
  • Good that you found a solution on this but it's very important to empathise that using a component to access an external datasource is not likely the best way. For further development of this kind of api's for example refer to these slides which are some important things to think about when designing this kind of solutions: http://www.slideshare.net/neilcrookes/designing-cakephp-plugins-for-consuming-apis – Luc Franken Jan 13 '13 at 11:38
0

Check out CakePHP's HttpSocket utility. I have not used it yet but I think it's just an API for cURL which sounds like what you need. http://book.cakephp.org/2.0/en/core-utility-libraries/httpsocket.html

Peter L
  • 51
  • 2