XF 2.3 Manual import via API?

ap3

New member
Licensed customer
Is this feasible at all? I am planning on importing a legacy non-website application. The user 'db' doesn't have passwords or emails in the first place due to single sign on, usernames would be guests with a custom avatar linked to a s3 bucket avatar folder at a well-known url containing the username.

Is it possible to write some custom code to POST to the API for each user and each thread, and request that a thread be created at a specific ID, or what ways would be best for this (very cursed) import? I am technically competent but new to traditional forums.
 
Is there a reason you wouldn't try to import this directly into the database?

The API is (as is normal for an API) intended to provide programmatic access to "standard" operations. So trying to manage your resource IDs isn't going to work, because the API explicitly isn't going to expose that since it's not part of the normal operations of the forum and risks breaking things.

If you want to use the API, because you're unfamiliar with the database schema or otherwise not interested in writing that much SQL, you'll have to manage and replace your source IDs with the new IDs that get created in XenForo. E.g. post a new thread using the API, read the thread ID in the response, and update your source data/links with the new thread ID. But the API isn't going to let you do granular manipulation of things like the date a thread was created or other such historic information that you might want to retain:

I think your best bet is a direct database import.

If you really don't care about a lot of the source metadata like dates, and are just trying to get the message content into the forum software, you could do what I described above - the code would have to do the action (create user), then either directly update the source data to reflect the new resource ID or build a mapping table that the rest of the import could consult.
 
I was nodding yes, anything is possible with the data and code until... "and request that a thread be created at a specific ID". XF will assign the next ID on insert. You won't have control of this without a LOT of fugery...

If you're trying to load something like a blog post into a forum, you need to do the mapping of the data.
Read blog?id=1
get the username
get the blog title
get the content
get the comments (loop)

and then create the user if not exists
collect the userid
create the thread (what forum? i suggest throwing it all in one place and moving it later, or if you already have categories that's another layer here, depends on qty of stuff moving)
thread relates to userid and forumid
create the replies foreach comments as comment, relate to the thread


it's a bit of scripting. As above, the api isn't going to be enough, but it could be your 'create' calls which will limit some overhead and relationships.

If you have a budget, there's 2 or 3 folks on here who specialize in imports from other systems. put a request out in the paid help request area.
 
Is it feasible to directly write INSERTs into the DB with something approximating what a guest thread and replies would look like / do I need to manually screw with sequences or autoincrements to force them to start at a certain point if I am directly writing into a database?

I'm fine writing SQL, was curious more whether hitting the API was "cleaner" or if there were any hooks that would trigger with a normal importer that I miss directly writing into the database?
 
Back
Top Bottom