I am working on a project where the user writes their content on one wordpress blog (as a draft) but wants it published on their own wordpress blogging site.
This seems strange but it is the core concept for the business as the writers are collaborative and so that's now what can be changed.
I've installed JSON api plugin. (I am totally new at api's and still in the first year of PHP).
I'm wondering 1. How you would use the json info from site A to create a post for site B.
So far I've conceptualized it as the following.
- the plugin(on site b) pulls the json info from site a
- the plugin then takes the json and turns it into an array (attempting to match as much of it to post info)
- then the plugin inserts the posts into site b's post db (I thought this would make it the fastest as this is something that twitter kindof does except for the data sits on your phone/computer??)
- The posts function as if they were created on site b (i.e. they follow the rules of the theme on site b).
So far EVERY attempt I've done to google and do it alone has resulted in horrible, horrible failure. (I have not fallen on my sword yet due to my high need of achievement.)
The first attempt was:
$response = wp_remote_get('urlhere/?json=get_post&post_id=120'); //$my_post = array($keys as $values); wp_insert_post($response, $wp_error);
However... no results (I put urlhere to create a more universal response and not just focus on the url of the actual site.
// Create post object $my_post_test = array( 'post_title' => "Hi this is a title!" , 'post_content' => "This is a test", 'post_status' => 'publish', 'post_author' => 1, //'post_category' => array( 8,39 ) ); // Insert the post into the database wp_insert_post( $my_post_test, $wp_error );
Second issue: This code produces 4-8 posts with the same title (seems strange?)
My questions are: 1. What is the best way to conceptualize the process so it's relatively scalable (i.e. 20-1,000 writers) 2. How would I get JSON api plugin to insert the data into a wordpress post code?