Create Post Programmatically - Image?
$feedData = [
'title' => 'Post Title',
'message' => 'Post Content', // in markdwon format.
'space_id' => 1, // 1 is the space id
'user_id' => 1, // 1 is the user id
];
// Additional Optional Data attribues
// for youtube or any other embeded video
$feedData['media']['url] = 'https://www.youtube.com/watch?v=video_id'; // youtube video url
$feedData['media']['type'] = 'oembed';
$feed = \FluentCommunity\App\Services\FeedsHelper::createFeed($feedData); // this will return $feed Model or \WP_Error
if(is_wp_error($feed)) {
// it's an error
} else {
// it's a success
$createdFeedId = $feed->id;
$permalink = $feed->getPermalink(); // full url of the feed
}
I have gotten this to work, but i'd like to use an 'image' in addition to the 'oembed'; I've tried 'image' or 'image/jpg' with the url to the image, but nothing works. i've also looked at the database and tried the 'featured_image' field, but that was a no-go. Any help would be appreciated.
We will add image support as well and update the doc in the next version.
Shahjahan JewelΒ Hello - I know you're at a conference, but wondered if you got a chance to do this and what the attribute ended up being? I tried a url and 'image' or 'image/jpg' but didn't work.
Safe travels.
Shahjahan JewelΒ I discovered this thread in search of the same as post author. Is it still in development? I can't find any references in documentation.
Stanislav NovokhatkoΒ We are improving a few details in the PHP API. We will update the documentation after the next update.
Thank you!! Game changer product.
I would like to add an image to programmatically created post too. Thanks.