Welcome, Guest
Username: Password: Remember me

TOPIC: Connecting to an API

Connecting to an API 19 Aug 2013 15:25 #10824

  • Storm
  • Storm's Avatar
  • Offline
  • New Member
  • Posts: 4
  • Karma: 0
Hi,

How can I integrate a connection to an API and then use the component builder to extract information from the API?

Thanks
The administrator has disabled public write access.

Connecting to an API 19 Aug 2013 15:39 #10825

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Hi and welcome to the community.

It depends what do you want to do.
Often, the use of JDom is a great choice becaue it automatically include all the requirements (assets : js/css/images/) in the right place.

For instance you can see how the google map is integrated in the tutorial.
www.j-cook.pro/index.php/m/many-to-many
Chapter 7 and 8

Hope it helps.
Coding is now a piece of cake
The administrator has disabled public write access.

Connecting to an API 19 Aug 2013 15:40 #10826

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Sorry, I think you mean an another type of API...
You want to get datas from this API and furnish them to your PHP source.

I need to know more about your request.
Coding is now a piece of cake
The administrator has disabled public write access.

Connecting to an API 20 Aug 2013 06:43 #10860

  • Storm
  • Storm's Avatar
  • Offline
  • New Member
  • Posts: 4
  • Karma: 0
Hi,

Yes I want to be able to connect to an API here:

apisandbox.inapub.co.uk

Basically, I want to build a Component which allows Admin users to be able to enter an ID (or set of ID's) in the new Component, which takes that ID from the connected API and displays them on the front-end of Joomla.

In principal it should be quite straight forward, but I can't work out how to get your Component builder to connect to an external API.
The administrator has disabled public write access.

Connecting to an API 20 Aug 2013 07:43 #10861

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
I do not know too.

Use fsocketopen() when you need to extract html or decode JSON.
Use simple iframes if you need only HTML.

What to say more ?
To build your URL, concat the values you need coming from Cook.

I cannot really help you more because I never used this API. But I am sure it is not a big deal.

fsocketopen() some code around. Try to find an example in order to simplify those calls.
Coding is now a piece of cake
The administrator has disabled public write access.

Connecting to an API 20 Aug 2013 07:45 #10862

  • Storm
  • Storm's Avatar
  • Offline
  • New Member
  • Posts: 4
  • Karma: 0
Thanks for your reply, I know the API uses REST to connect, does that help at all?
The administrator has disabled public write access.

Connecting to an API 20 Aug 2013 08:32 #10863

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Yes, it is was I saw.

Well, it is exactly the same than AJAX if you want.
AJAX can return formated HTML, or JSON object. (or else, but to undestand)

It depends your requirements and how you will integrate it. But of course Cook can do that, because it does already for ajax.
The only difference is instead of calling a local uri, you call a non local.
Coding is now a piece of cake
The administrator has disabled public write access.

Connecting to an API 20 Aug 2013 08:45 #10864

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Also :

If you need the returned datas interpretable by PHP, you need a socket.

If you want html integrated without frame, you need a socket too.

If you want only simple formated HTML (iframe)

If you need to decode JSON in javascript, use Ajax query

Hope it helps. I cannot do the job for you.
I am curious about the following of your adventure.
Coding is now a piece of cake
Last Edit: 20 Aug 2013 08:46 by admin.
The administrator has disabled public write access.

Connecting to an API 23 Aug 2013 07:07 #10891

  • Storm
  • Storm's Avatar
  • Offline
  • New Member
  • Posts: 4
  • Karma: 0
HI,

Thank you for your replies so far, I do have one more question, where can I put the connection information in the Builder? I want to purchase your builder but I want to make sure it can connect to the API first and I don't know where to do it. Pleas help.

Thank you
The administrator has disabled public write access.

Connecting to an API 23 Aug 2013 14:54 #10897

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Oh no, there are no ready-to-go feature for that.

You have to code inside your component.
It is not a big deal, but I cannot explain you in details all the way how to do it.
If is it your first component, first understand how the views are calling the datas.
and how the models are loading and filtering the datas...
etc...

Then, it depends the way you choose to call the API (Ajax and JSON result, fsoketopen, iframe...)
I cannot help you more.
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: kreeer
Time to create page: 0.109 seconds

Get Started