How to like a page on fanpage on facebook without a mouse - java

BACKGROUND
I'm doing an interactive art project for school.
PROCESS
For this project the last step is to go to a facebook fanpage and like the facebook page.
ASSUMPTIONS
I'll be using Java to open up a browser and then go to the facebook page. However, I would like to use something like one line of script to like the facebook fanpage.
PROBLEM
Is there will be no mouse for this interaction.
SOLUTIONS
Is there a script I (or stackoverflow) can write that I may execute that will like a facebook page?
Or is there any other solution that you guys can think of?
TOOLS/LANG. BEING USED: ARDUINO/JAVA, HTML, JAVASCRIPT and CSS.

You could use a browser automation framework like Selenium to load the Facebook page and simulate clicking on the Like button, but you would have to log the correct user in first. Selenium has a Java interface you could use.
Alternatively, if you are having it run on a single machine you control, you might have luck with doing some sort of userscript (something like this one) for the Facebook site so that when they are on the correct page, it clicks the Like button automatically. Then all you would have to do is launch the page from Java in the correct browser, and the userscript would do the rest. Note: Userscripts work on Firefox with GreaseMonkey installed, and on Chrome/Chromium without any extensions.

Make an application on Facebook and use their api to interact with the page: Facebook API
Alternatively, use some javascript to like the page once you navigate to it

Related

Interacting with a webview (JAVA ANDROID)

In my app I have a webview to show the user some information from a web page. Before seeing the info though, you have to choose an option on a dropdown list on the webpage. Is there any way I can choose the right option for the user (via code) and only have them see the content?
You can run arbitrary javascript inside a WebView, initiated from Java. Be sure you have javascript enabled. Once you've done that,
theWebView.loadUrl( "javascript:alert('Hello')" );
is the mechanism to invoke javascript functions or scripts. To pre-select a drop-down, you may want to include jquery or such, making the selection easier.

Submit a review(data) through android app on a url

I want to add a functionality in my app which submits a review of a place on the place's google plus account ..
As you might be knowing the format of the google plus page ..
It has a button "Write a review" (Which is not a button but a clickable 'div')
On pressing this button , a dialogue appears which has a field to write review , It is here i want to actually write the review through the code and press the submit button .
Please help me through this ..
How to achieve this thing ??
Jsoup parses HTML. It does not execute JavaScript or emulate a browser, so there's no dialog box for it to interact with.
You could try using a browser's network monitor feature (part of their developer tools) to see what requests are made when the dialog box is submitted, then simulate those requests from your application. You could also see if there's a Google+ API for submitting reviews other than from the place's Google+ page. APIs are easier to use, robust against changes in the web page's HTML, and don't risk violating terms of service that prohibit automation. Finally, you could try a browser automation tool (commonly used for unit testing web pages); I don't know of any for Android but I'd be surprised if there aren't any.

Java show OAuth webpage

I am developing a Java desktop application and need to access the LinkedIn API. In order to do this, the user has to login on the webpage that LinkedIn sends me back. But how can I easily integrate that in my application?
JEditorPane is not meant to show html pages and it really does not look good at all, so that is not an option.
Thanks in advance!
Have You seen Scribe? It has LinkedIn support out of the box, looks like you may be able to use it...
https://github.com/fernandezpablo85/scribe-java/blob/master/src/test/java/org/scribe/examples/LinkedInExample.java

How does Java interact with buttons on http webpage?

I have little knowledge about web programming, and I was looking through a lot of examples which gives alot of examples about writing on the webpage for web browser to see, but nothing about getting request when user presses a button the webpage.
For example, upon opening the server, it opens the port 80, then I want to go to web browser and type "localhost:80" to access the webpage made by the server client. The webpage has a button which when I click it, webpage changes to something else like "Clicked!".
Can someone show me an example code of this? Link to an example would be great as well.
Thank you very much.
I would recommend using something like Apache's HttpClient to imitate a button press, which is just an HTTP POST. And if you don't want to use a third-party library, the standard Java library already rolls its own.

Is it possible to add a facebook like button on a Java application?

I don't want a pop up, I want an actual Facebook like button, has anyone got any idea how I would go about it? Is it against Facebook policy?
Thank you
I don't think this is anything specific to Java. Just use whatever method of generating HTML you are using, and put the tags in to load the Facebook javascript SDK and put an fb:like element on the page.
Currently there is no API by which you can create a Like directly - the only way a user may "Like" something on Facebook is using their Like button code embedded in the standard way.
You can create your own actions on the timeline that look like a "like", you just need their permission. You can use OAuth to get that, google can help you find examples of Facebook clients in Java.

Categories