12 Posts
7 years ago

Hi there, I'll try to explain what I want in different manners...

I'm looking for a way to insert and update data represented as JSON (or any other format) as a piece of 'content' (part of a contenttype). 

I'm looking for a way to import, but automatically (not via the importer plugin). The import should not be told about the chosen storage. I'm looking for an easy way to 'hook-in'. Is it possible. I couldn't find documentation about this, nor by quickly walking trough the code. 

I'm looking for something like ...

<?php  // I'm just making this all up! .....


$sebapp = new sebApp;

// get data from a webservice. For ex. a book (say that the key/value pairs are exactly named as would be expected later)
$jsonData = file_get_contents('http://restul.api/book/123')
$book = json_decode($jsonData);

// insert the book (there's a content type 'books'
$sebapp->insert($book, 'books');

// or $sebapp->update($id, $book, 'books');

Does anyone have more information on this? A while ago (1 year ago) I noticed some 'interface' in the code. But can't find it anymore nor anyone mentioning is. Am I looking over it? 

Thank you in advance.

Get a VIP membership
12 Posts
7 years ago
Level 2

Tnx Klas! I'm helped perfectly. I looked over that topic. 

8 Posts
7 years ago
Level 3

hi good day . Glad that helped you . could you tell me where should coloado this code so that I can work ? I found an article that creates native joomla , put this code can not make it work. see the code below , works perfectly should only be within the project and with the correct directory : Ps . If you can help I would be very grateful.

<?php if (!defined('_JEXEC')) { define( '_JEXEC', 1 ); define ('JPATH_BASE', 'D:\xampp\htdocs\curl'); require_once ( JPATH_BASE .'/includes/defines.php' ); require_once ( JPATH_BASE .'/includes/framework.php' ); $mainframe = JFactory::getApplication('site'); } function getContentTable($type = 'Content', $prefix = 'JTable', $config = array()) { return JTable::getInstance($type, $prefix, $config); } function addArticle($title, $alias, $metadesc, $introtext) { $table = getContentTable(); $table->title = $title; $table->alias = $alias; $table->introtext = $introtext; $table->metadesc = $metadesc; $table->catid = 2; $table->state = 1; // and so on! // then save it $table->store(); } $result = addArticle("aajsohnatsahan", "aamaratssins", "asaajohn", "esse é um tsexto de introducao");

Get a VIP membership