0

So, this is a two parted question but both pertaining to REST APIs. I am developing a component for Joomla in which I have a few database fields (ie. teamid and platform) that are stored in the local db. These two fields correlate to a rest API from an external source.

If table #__nhlleague_team table has the three fields:

ID, teamid, platform

The API I am pulling from in general is

https://proclubs.ea.com/api/nhl/clubs/info?clubIds=*teamid*&platform=*platform*

for example

https://proclubs.ea.com/api/nhl/clubs/info?clubIds=196556&platform=xboxone

So, the question is - how do I insert the GET request in the Joomla Component? Would it be its own function in the Model? I just need the data to be displayed based on those parameters, and have no idea how to implement in the component.

1 Answer 1

0

I would say it is probably suited as a function/method of a Model as it is accessing data, some people might put it in a sub-controller, however I don't believe Controllers are supposed to deal with data.

These are the basic lines that you need to set up your request, make the call and then output the results.

    use Joomla\Http\Http;
.
.
.
    $url = 'https://proclubs.ea.com/api/nhl/clubs/info?clubIds=196556&platform=xboxone';
    $http = new Http();
    $reponse = $http->get($url);
    print_r($reponse);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.