By Prakash Reddy on Friday, 04 March 2016
Posted in Technical Issues
Replies 3
Likes 0
Views 305
Votes 0
Hi Team

After attending JWC15 Bangalore session, we started using Ionic framework/Cardova to build our mobile app for doctors as part of our product offerings to Healthcare.
It has EasyBlog post creation as one of the feature from mobile.
We could able to write a blog with camera integrated and post to Joomla backend.

Now I want to auto post newly posted blog to the user's social channels(FB/Twitter). I'm using EasyBlog API to save blog from mobile.
If I create a blog from Joomla frontend then it started doing auto post.

I'm using Easyblog API plugin offered by Parth (TechJoomla guys) and trying to integrate blog post to Auto post from mobile the way we've done for Joomla frontend.

It looks like the API's content generation events are not as per Easyblog's.
Can you please help me in understanding what needs to be done to get auto post triggered.

For reference, I'm including Blog Post API function, it uses EasyBlog's model to post the content:
public function post() {
$input = JFactory::getApplication()->input;
$blog = EasyBlogHelper::table( 'Blog' );
$data = $input->post->getArray(array());
$log_user = $this->plugin->get('user')->id;
...
$post = EB::post(NULL);
$post->create();
$key = 'post:'.$post->id;

$data['image'] = '';
if($file['name'])
{
$image_obj = $this->uploadImage($key);
$data['image'] = $image_obj->media->uri;
}
//document needs to get from app
$data['content'] = $input->get('content', '', 'raw');
$data['document'] = null;
$data['published'] = $input->get('published', 1, 'INT');
$data['created_by'] = $log_user;
$uid = $post->uid;
// Load up the post library
$post = EB::post($uid);
$post->bind($data, array());
// Default options
$options = array();
// check if this is a 'Apply' action or not.
$isApply = $input->post->get('isapply', false, 'bool');
// For autosave requests we do not want to run validation on it.
$autosave = $input->post->get('autosave', false, 'bool');
if ($autosave) {
$options['validateData'] = false;
}
// Save post
try {
$post->save($options);
} catch(EasyBlogException $exception) {
$this->plugin->setResponse( $this->getErrorResponse(404, $blog->getError()) );
return;
}
$bpost = EB::post($post->id);
// $post->bind($row);
$item = EB::formatter('entry', $bpost);
$scm_obj = new EasyBlogSimpleSchema_plg();
$item = $scm_obj->mapPost($item, '<p><br>
<a><blockquote><strong><h2><h3><em><ul><ol><li><iframe>');

$this->plugin->setResponse( $item );
}

Thanks
Prakash
Hello Prakash,

In order to get autoposting to work, there are several things you need to check. First, make sure the post is published. Then you need to check whether the category you are posting to has permission to allow autoposting or not: http://screencast.com/t/MozTqmrfO . Since you are able to autopost when creating a blog post from frontend, I believe you have successfully configured Facebook Autoposting here: http://screencast.com/t/UaSf4SSu4L . Hope this helps.
·
Friday, 04 March 2016 18:28
·
0 Likes
·
0 Votes
·
0 Comments
·
hi Nick

Thanks for the reply.
My question is related to trigger autopost from an API (mobile app integration) which will create a new blog in EasyBlog. Apart from "onAfterEasyBlogSave" trigger, is there anything else to do for auto posting to happen.

-Prakash.
·
Friday, 04 March 2016 18:37
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Prakash,

I am sorry for the delay of this reply.

Apart from "onAfterEasyBlogSave" trigger, is there anything else to do for auto posting to happen


Em, i not sure if i understand your above or not but autoposting is actually happen automatically the moment you call from your php code:

$post->save($options);


You might want to take a look at file 'JOOMLA/administrator/components/com_easyblog/includes/post/post.php' at save() function and postsave() function. The autoposting actually process in postsave function.

Let me know if you need further clarification on the above

Hope this help and have a nice day!
Sam
·
Saturday, 05 March 2016 13:33
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post