Simulate a click, how to share a link to Google+ without clicking

Asked

Viewed 242 times

2

My challenge is to share my site to Google+ without clicks.

I have a google account [email protected], I created a profile on G+.

The idea is through localhost create a script where when accessed it will perform the task of sharing a link in the G+.

Good in the researches I performed, in G+ there are several types of profiles:

Common profile of a person

A community

And a page

In the documentation of the Explorer we see 2 distinct Apis for the G+:

And in the comparison table it is said:

G+ API "Write posts to the stream" NO

G+ Domains API "Yes, Restricted to the Domain."

I couldn’t understand the workings of this API "Domains"

For this reason and for seeing several questions about it saying that there is no public API to automatically post to the G+ is that I gave up using the API.

So I’m trying to use sharing and simulate confirmation clicks to automatically share a link from my website to G+, from this code:

<!doctype html>
<html>
    <head>
        <title>Teste share G+</title>
    </head>
    <body onload="alert('hiii');document.getElementById('share_g').click();">
        <a href="https://plus.google.com/share?url=http://www.example.com" id="share_g" onclick="javascript:window.open(this.href,
  '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');document.querySelector('span.RveJvd snByac').click(); return false;"><img
  src="https://www.gstatic.com/images/icons/gplus-64.png" alt="Share on Google+"/></a>

    </body>
</html>

However it is necessary to click the button POSTAR to perform the operation, there is some way to simulate this click. with javascript or phantomjs?

Any other solution is welcome.

  • You can simulate with jQuery $("element"). click(); and with javascript: Document.getElementById('element'). click(); but by default the simulation only works with some user event, you cannot do the simulation alone.

  • You’re trying through page X to fire an event click on a window Y that was opened by an event click on X?

  • @Anthraxisbr doesn’t even know what I’m trying anymore,,, I need to share a link to my website for the G+ with no click...

  • @Magichat I think that this way there is no way not, because you would have to fire an event in a window through another, I think put an iframe with the link of g+, fill the iframe and trigger the right click, da para fazer tudo Hidden.

  • Pressing the link opens a new window for sharing. Do you want the "Post" button to be automatically clicked? Even if this is possible, this would not share the link every time the page was loaded?

  • @Andersoncarloswoss At the moment the challenge is to share the pro G+ site without click, if possible (I’m sure it is) then you can take some steps to make it happen only when necessary.

Show 1 more comment

1 answer

0

Use something like this:

document.getElementById('elementID').click();

Supported including in the IE

With jquery you can do so:

$("#mytest1").click();
  • Thank you for your attention, this only works in the same field, which is not the case.

  • Even this code is already present in the event onload of body in the question, then it would be fundamental to explain why the question code did not work, if this were the solution.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.