Pregunta

I want to post the node link along with its title in social media (Twitter, Facebook, and Google+). Node link should be posted only if the content is published.

I have used the HybridAuth and Facebook OAuth (FBOAuth) module for Twitter, Google+, and Facebook login.

How can I achieve this?

¿Fue útil?

Solución

For Facebook and Twitter you should be able to get this to work using the Rules module, though for Google+ this sounds like a business opportunity (read: no known solution as of today). Read on for more details about each of them ...

Facebook

The Facebook Rules module can be used to post to user's wall, via the Rules module. Some more details about Facebook Rules (from its project page):

Facebook rules module extends FBOauth permissions and integrates with Rules module.

Once the user's Drupal Account is connected to his/her FaceBook Account, FaceBook Rules can be used to set up actions based on particular events or triggers.

It provides following rules:

  • Events:

    • User logged in using Facebook connect.
    • User connected existing own account to Facebook.
    • User registered using Facebook connect.
    • User registered using Facebook connect, requires admin approval.
  • Condition: User's Drupal account is connected to Facebook account.

  • Action: Post to user's wall.

Twitter

After you enable the Twitter module, and its sub-module Twitter Actions, you can use the Rules module to create an action that will post a tweet to a specific Twitter account.

Have a look at Post Automated Tweets Using Rules and Twitter Actions for more details about it.

Google+

For Google+ I'm not aware of any working solution. Yes there is the Google+ module (which only has a dev version for D7 ...). And yes Google+ does have an API, but this module doesn't implement it.

Therefor I think the best you can find (to start from) is what is described in How to post in google plus wall?. Starting from there, you may get that to work also if you'd write your own (custom) Rules (Event(s), Condition(s) or Action(s)), similar to what is described in the answer to the question about "How to login-redirect users to their profile page on specific days only?".

PS: Using the Rules module to make something happen when something gets "published" should be a no-brainer (that's like Rules lesson 101, which I assume does not need any more explanation).

Otros consejos

I would think very carefully about what you want to achieve by auto posting, and what level of upkeep you want to invest in this. Do you really want everything going to every one ?

Think of things that can go wrong (post a typo, then repost it, update all your articles - all the posts re-broadcast, api's change - I've seen them all).

What I would probably do in the first instance is look at something that polls your site, and posts for you, rather than having it sit within a site. That takes away some of the upkeep of apis and the like.

Zapier is excellent for this - RSS by Zapier lists a number of the possible integrations by creating an RSS feed on your site and having Zapier use that.

IFTTT is also excellent for this.

I'd also add buffer into the mix that handles timing of pushing content cleverly, so you push it at a good time, when it's likely to be read.

These can all post to all the networks for you, and add many more features besides.

To achieve what you want, my suggested approach would be something like the following:

  • create a view for published content you want to post, add a field (defaulting to true if you'd like) to specify include.
  • set up an integration with either IFTTT or Zapier to poll these feeds.
  • set that integration up to push these items into buffer and have buffer manage the posting for you.

I know it's not a sexy code based solution - but I'm of the opinion just because you can do it with Drupal, you shouldn't also look at what else has been done, and how others achieve this kind of thing (getting off the island).

This way is scalable, reliable - takes away a lot of the integration pain, and in my experience works really well.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a drupal.stackexchange
scroll top