Share content on facebook with vb.net? - vb.net

I'm currently searching for an method to share content on facebook if the user click on a button or when an event is true, how can I do this?
Thanks in advance! :)

You can call the facebook share dialog and supply the URL of the site that you want to share. For example
https://www.facebook.com/sharer/sharer.php?u={URL_OF_THE_SITE}
Now, you have to call this inside your VB.NET application. If you are using the WebBrowser, you can call the Navigate(String) method. Or, if not, you can call the default browser using the start command. You will need to call the Shell function for this. Example:
Shell("start https://www.facebook.com/sharer/sharer.php?u={URL_OF_THE_SITE}")

Related

WKWebView - replace web action

Inside my app, I'm using the WKWebView to display a website. My goal is, when user is pressing a button on this website, I want to stop an action linked to this event and replace it with my own, natively made (custom action outside the WKWebView). I've been trying to search for any solution to fetch mentioned event but unsuccessful. What more came to my mind, if there is a way to fetch a JavaScript in WKWebView, I have a possibility to add some JS script code to this site (not to delete the action I want to block). Thank you for any help.
First, do you have a permission to mess with this web site's behaviour? I assume you do, otherwise it is likely illegal.
Second, try using Safari Web Inspector with a device/simulator, and use the DOM tree and console tools to find out what is the HTML/javascript that is involved with this action on this site.
If you can't find what happens in HTML/JS yourself, feel free to post a new separate question on SO with your target URL, some HTML/JS code, and which link/action you want to replace. Tag the question with "javascript" and ask if it is possible to write some javascript to replace that particular action to some custom JS code.
Usually there are 2 types of actions: either it is something that provokes AJAX calls to a server API triggered by an event handler, or it is a plain HTML link that results in a web navigation. For both cases it is possible to write a JS script that overrides the action.
Finally, use WKUserScript to inject javascript into the page, and override the action. Use window.webkit.messageHandlers to send an event from your custom action to the app side. Use WKScriptMessageHandler to process the event in the Objective-C or Swift code.
See an example here: http://nshipster.com/wkwebkit/

Showing file selection UI : Integrating Dropbox with OAuth 2

I am trying to create a web page which will allow my user to upload a file to my S3 storage. For choosing the file user can use Google Drive, Dropbox and also local system. Am facing issues while implementing the Dropbox part of this.
Am using this technique for integration(using core API and OAuth 2).
First when user chooses Dropbox i am opening an HTML page in an IFrame. Here I have an authorize button which will open the authorize endpoint mentioned in the above link. This link shows me X-FRAME-Options error inside the Iframe so i had to open this link as a popup to work.
Is there a way around this? I'd like the authorize URL to open in the same iframe by using location.href.
Also when i open it as a popup, after the user logs in successfully the redirect_uri which i pass i getting opened in the popup. I had to do some unconventional setInterval coding to go around this. Can someone suggest a solution for this as well?
I also tried using CSRF tokens as mentioned in Smarx's blog but this also gives me the same error.
EDIT :
#smarx i tried using dropbox.js and it works fine. Stuck at one place
I used the OAuth popup driver and have a button which says sign-in.
First on load i create the client and then the popup driver as below
client = new Dropbox.Client({ key: client_id });
client.authDriver(new Dropbox.AuthDriver.Popup({
receiverUrl: "http://localhost/uploadCare/dbcallback.html"
});
);
And in the call back html i am writing
Dropbox.AuthDriver.Popup.oauthReceiver()
as mentioned in the docs.
But this does not take me back to the original page and show me the list of files.
I particularly did not understand this part of the explanation
"To use the popup driver, create a page on your site that contains the receiver code, change the code to reflect the location of dropbox.js on your site, and point the Dropbox.AuthDriver.Popup constructor to it."
Could you please help me out here.
You definitely can't put dropbox.com into an iframe, for security reasons (e.g. clickjacking).
A few suggestions:
Can you just use the Chooser for your use case? That would certainly be easier for you and your users.
If you can't use the Chooser, is there a reason you're not using dropbox.js? It has a popup auth driver that will pretty much just take care of all this for you. The redirect will definitely happen in the same window as auth, so communication between the windows (usually via localStorage) is generally necessary. This is already done in dropbox.js.

How to embed BrowserID login button in the defaultLayout

Part of the beauty of BrowserID is that it requires very little in the way of infrastructure on your website, you simply embed a button with some javascript and then setup a callback route to handle the post-authentication data. I would like to be able to embed the BrowserID login button at the top of all of my pages inside of the defaultLayout template (and then conditionally show/hide it based on the login state), but I currently see no way to do this. The Auth subsite works by embedding its "login page" inside of the defaultLayout template, but aside from that seems to be a complete blackbox.
I'd really like to be able to avoid either rolling my own handler for BrowserID login or redirecting the user to a completely seperate page that just has a single BrowserID login button on it if at all possible.
Is there a way to accomplish what I'm trying to do that I'm just missing, or is my best bet really to roll my own BrowserID login code?
Looking at the source code for the Yesod.Auth.BrowserId module it looks like I might be able to do something like:
(apLogin authBrowserId) <not sure what would go here>
in order to get the login widget, but hijacking the guts of the plugin like that feels dirty.
You can use createOnClick to generate a Javascript function, and then insert whatever kind of button/link/image on your page. Just attach a click handler and have it call that function.

Make Web Browser control communicate with VB.NET Program

What I am looking for here is a way to possibly click a button inside a web browser control and have it call a sub from inside the program or have the program react to something on the page.
I am trying to make a HTML5 GUI for my application. I don't really want use any 3rd party API's to handle commands from a HTML5 interface but if I can find another alternative that would be good. But if there is no other way I would be content with using a 3rd party API.
The way I have done this in the past is to specify a special protocol for my app.
yourapp:somefunction/someparameter
Handle the Navigating event, and in your code for when that event is fired, check to see if the URL has your protocol on the front of it. If it is, set e.Cancel = true to cancel navigation, and add code to handle the URL parameters yoruself.

Is there a way to programmatically click links, input info into login forms, etc in Objective-C? (like Mechanize does)

Is there anything similar to Mechanize for Objective-C? I want to enter info into a search bar, select a link, and then extract some information from the webpage
You can either run JavaScript code in the context of your WebView or interact with its DOM yourself.
You can inject javascript into the page to do what you want with stringByEvaluatingJavaScriptFromString. For example to simulate a click, inject:
getElementById('the_button').click();