Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
virap1 Posted March 2, 2023 Posted March 2, 2023 Is there an easy way to move large content from blogs to database and setup redirects? Thank you. The Old Man 1
Ryan Ashbrook Posted March 2, 2023 Posted March 2, 2023 Unfortunately, there is no functionality to do this in the software at this time.
virap1 Posted March 2, 2023 Author Posted March 2, 2023 17 minutes ago, Ryan Ashbrook said: Unfortunately, there is no functionality to do this in the software at this time. I see your post saying there is no such solution at all is marked as a solution. That is both funny and sad.
Adriano Faria Posted March 2, 2023 Posted March 2, 2023 I’m not 100% sure of this but I think I have a converter for this task. I’ll reply back tomorrow in the morning after confirming. virap1 1
Jim M Posted March 2, 2023 Posted March 2, 2023 1 hour ago, virap1 said: I see your post saying there is no such solution at all is marked as a solution. That is both funny and sad. Keep in mind, it is the answer to your question pertaining to our core software we're going with here. Of course, that may not be a resolution to your problem. I have unmarked the solution and moved this to our Community Support forum as it is moving towards a custom resolution.
virap1 Posted March 2, 2023 Author Posted March 2, 2023 So tried to see if I can use the Rest api to get the blog records and move them to the database, but I am getting "401 Unauthorized" error saying "errorCode": "3S290\/9", "errorMessage": "INVALID_ACCESS_TOKEN" Here is the base php code <?php // IPB REST API settings $api_url = 'https://your-forum-url.com/api/rest/'; $api_key = 'your-api-key'; // Set up the API request $request_url = $api_url . 'blog/posts?sortField=date&sortOrder=asc&limit=1'; $request_headers = [ 'Authorization: Bearer ' . $api_key, 'Content-Type: application/json', ]; // Send the API request $ch = curl_init($request_url); curl_setopt($ch, CURLOPT_HTTPHEADER, $request_headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); // Check for errors if (curl_errno($ch)) { echo 'Error: ' . curl_error($ch); } else { $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($http_code !== 200) { echo 'Error: API returned HTTP code ' . $http_code; } else { // Parse the API response $posts = json_decode($response, true); // Display the oldest post data $oldest_post = $posts['results'][0]; echo '<h1>' . $oldest_post['title'] . '</h1>'; echo '<p>' . $oldest_post['content'] . '</p>'; } } // Clean up curl_close($ch);
Adriano Faria Posted March 2, 2023 Posted March 2, 2023 49 minutes ago, Adriano Faria said: I’m not 100% sure of this but I think I have a converter for this task. I’ll reply back tomorrow in the morning after confirming. 48 minutes ago, virap1 said: Thank you Adriano FYI, the converter I may have, beyond copying the entry into a record, it also take care of comments, reactions and followers. The Old Man and virap1 2
The Old Man Posted March 3, 2023 Posted March 3, 2023 I've been trying for some while now to do this and was hoping Adriano had a plugin to do it! My members have not used Blogs for several years, but of the 30 or so blogs with 400 comments, I really wanted to preserve a few from members who have passed away or where they were behind-the-scenes-style community project blogs. I've had mixed results with RSS, as some RSS feeds don't include the formatting and of course, you lose the associated comments, tags and reactions. I didn't try REST API for this but I did use that to convert from IPS Gallery to WordPress Gallery which worked fine for my needs. I've just started getting familiar with GraphQL which seems useful. I know it's a one-time conversion to move Blogs to Pages, but Adriano if you have an existing solution that would be a big time saver.
The Old Man Posted March 3, 2023 Posted March 3, 2023 17 hours ago, virap1 said: So tried to see if I can use the Rest api to get the blog records and move them to the database, but I am getting "401 Unauthorized" error saying "errorCode": "3S290\/9", "errorMessage": "INVALID_ACCESS_TOKEN" If you get your key working, you may not need this but I had a similar difficulty and found that it was easier to Authorize the requests by sending the API key as the key parameter in the request, a key locked down to the server by IP in IPS. Also to avoid "PHP Warning: parse_url() expects parameter 1 to be string, array given", the request needs to be a concatenated string, not an array. $request = $communityUrl . $endpoint . "?key=". $apiKey;
The Old Man Posted March 3, 2023 Posted March 3, 2023 (edited) 17 hours ago, virap1 said: $api_url = 'https://your-forum-url.com/api/rest/'; The endpoint might not be correct, I used /api/core/hello for example but we were on 4.3 back then. // Test Connection to IPS REST API and display response function invTest_ipsHelloTest_shortcode (){ // Authorize the requests by sending the API key as the key parameter in the request. Locked down to server by IP in IPS. $communityUrl = 'https://example.com/mycommunity'; $apiKey = 'hfquhgfhwuhguwhruggqwrhghwrhg blah'; $endpoint = '/api/core/hello'; // NB To avoid "PHP Warning: parse_url() expects parameter 1 to be string, array given", the request needs to be a concatenated string not an array! GS $request = $communityUrl . $endpoint . "?key=". $apiKey; // GET the remote request headers and body $response = wp_remote_get( $request ); // GET just the remote response body $response_body = wp_remote_retrieve_body( $response ); // GET the remote response code and message $http_code = wp_remote_retrieve_response_code( $response ); $http_message = wp_remote_retrieve_response_message( $response ); // Check for error if ( is_wp_error( $response ) ) { return sprintf( 'Oops. The URL %1s could not be retrieved.', $request ); } // return something if not an error if ( ! is_wp_error( $response ) ) { // Uncomment to debug and show headers and body return $results = '<pre>' . print_r($response, true) . '</pre>'; // Uncomment to debug and show just the body! // return $results = '<pre>' . print_r($response_body, true) . '</pre>'; // Uncomment to debug and show the status code e.g. int(200) // return $http_code.' '.$http_message; } } Edited March 3, 2023 by The Old Man virap1 1
virap1 Posted March 3, 2023 Author Posted March 3, 2023 Thank you very much @The Old Man The Old Man 1
Recommended Posts