This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

smarbos8491
smarbos8491

Hello. Im trying to create a plugin to interact with MercadoLibre's API. Can someone give me a hand on what's steps should i follow? Im a little bit lost. I can make the api work, but dont't know how to integrate it into the plugin. Should i copy the SDK files into the vendor directory? Or should i use composer for installing it? Its any difference? What's next? Thank you a lot!

daftspunky
daftspunky

You can use composer.json, look at the demo plugin to see an example. For testing you can run composer install inside the plugin directory. If you decide to publish the plugin, then don't include the vendor directory, the server will build it for you.

Alternatively you can go old school and just include the files you need.

smarbos8491
smarbos8491

I do the composer.json file and it installed thepackage succefully! Now, i need to initialize the plugin Should i put this code inside the Plugin.php or should i put it inside a component and include the component in the page? Thank you very much for your help!


    $meli = new Meli(array(
        'appId'         => 12345,
        'secret'        => dsadsaDWFfs24DF34dgg43T3,
    ));

Last updated

smarbos8491
smarbos8491

I put the code above inside a component, and include the component inside a page. When loading the page i get


Class 'Damianm\Mercadolibre2\Components\Meli' not found

How should i reference the Meli class that i download with the composer and its now in my Vendor's folder?

Renatio
Renatio

Try this way:

$meli = new \Meli([
    'appId'         => 12345,
    'secret'        => dsadsaDWFfs24DF34dgg43T3,
]);

If Meli class have any namespace you should use:

new NAMESPACE\Meli()

Use good editor and it will import necessary classes for you. E.g. PhpStorm.

If you want to share this plugin with others, you should consider using October Settings Model to pull credientials from database.

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.