Welcome Guest, Not a member yet? Register   Sign In
Calling an external API
#1

[eluser]RaBu[/eluser]
Hi,

I'm new to CodeIgniter, I'm currently writing a simple PHP powered webapp using CodeIgniter (I'm really amazed over the simplicity and power of this cool framework).

My question is: How do I send a HTTP GET (or POST) to an external URL in a Controller or Model (with out sending it to a view).

E.g.: I want to call an external API (using HTTP GET or POST), then i construct my URL (http:// api.example.com/DoStuff?action=someThing&key=XXXX&whatEver=someThingElse) after that I want to fire it off, read the response and then forward to a relevant view.

I hope one of you more experienced CodeIgniter guys can help me, with a point in the right direction Smile

Kind regards,
Rasmus
#2

[eluser]Seppo[/eluser]
The only library CI has for a http client is the xml-rpc... if you need another type of connection, you can use the php natives: curl or fopen/fsockopen.
#3

[eluser]RaBu[/eluser]
Thanks for the tip, I just found this Curl-lib for CodeIgniter: http://alexpolski.com/category/curl-library/ (http://codeigniter.com/wiki/Curl_library/)

I will just check it out, sound like that's what i need Wink

- Ras




Theme © iAndrew 2016 - Forum software by © MyBB