By Govind Prajapati on Monday, 03 April 2017
Posted in General
Replies 6
Likes 0
Views 206
Votes 0
We needed one routine or feature,

Auto posting of Post from past based on some query (Query criteria is ok, that we can manage)
but need to know routine call via cron where given array of post ID gets autoposted on social media.

Please help how we can call to Autoposting function from our plugin code.
Like which class / files / frame work to include and call function by passing an array or iterating on for loop

Thanks for same in advance
Currently we do not have any API to allow autopost to social media, but I will explain how it work when you click social button from backend blog listing page, you can check my attached screenshot below which place i mentioned.

When you click share button from the dialog, it will go to this blogs controller php file.
JoomlaRootFolder/administrator/components/com_easyblog/controllers/blogs.php (function autopost())
When it call following autopost function, it will go to post library.

$post = EB::post($id);
$post->autopost($oauth->type, true);


This is post library php file -> JoomlaRootFolder/administrator/components/com_easyblog/includes/post/post.php then it will call this function autopost()

Then you will see it will call this following method to proceed autopost :

EB::autoposting()->shareSystem($this, $type, $force);

The file is located at JoomlaRootFolder/administrator/components/com_easyblog/includes/autoposting/autoposting.php (function shareSystem())

After that it will call this push method.

$table = EB::table('OAuth');
$table->load(array('type' => $type, 'system' => 1));

// Push the item now
$table->push($post);

This method is located at this file JoomlaRootFolder/administrator/components/com_easyblog/tables/oauth.php (function push())

This is the part get all the post data and send to Facebook.

// Now we do the real thing. Get the library and push
$lib = EB::oauth()->getClient($this->type, $key, $secret, $callback);
$lib->setAccess($this->access_token);

// Try to share the post now
$state = $lib->share($post, $this);

That share method is located at this file -> JoomlaRootFolder/administrator/components/com_easyblog/includes/oauth/adapters/facebook/client.php

And the Facebook API is located at this file -> JoomlaFolder/administrator/components/com_easyblog/includes/oauth/adapters/facebook/base_facebook.php

Hope this will help.
·
Monday, 03 April 2017 18:45
·
0 Likes
·
0 Votes
·
0 Comments
·
Ok, will get my hands dirty with this, and let you know, if its good,
The references you showned, I think I need just this (Just confirming is it ost or post?)


$post = EB::oost($id);
$post->autopost($oauth->type, true);


I guess : p together went to smily
·
Monday, 03 April 2017 18:52
·
0 Likes
·
0 Votes
·
0 Comments
·
yes, that is true, it should contain the p.

[gist type="php"]
$post = EB:post($id);
$post->autopost($oauth->type, true);
[/gist]
·
Monday, 03 April 2017 18:58
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post