Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <gtk/gtk.h>
- #include <webkit/webkit.h>
- void
- set_fake_mobile (WebKitWebView *web_view)
- {
- WebKitWebSettings *settings;
- settings = webkit_web_view_get_settings (web_view);
- /* This is based on the HTC Wildfire's user agent. Some
- * providers, like Google, refuse to provide the mobile
- * version of their authentication pages otherwise. eg.,
- * in Google's case, passing btmpl=mobile does not help.
- *
- * The actual user agent used by a HTC Wildfire is:
- * Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; HTC Wildfire
- * Build/FRG83D) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0
- * Mobile Safari/533.1
- *
- * Also note that the user agents of some mobile browsers may
- * not work. eg., Nokia N9.
- */
- g_object_set (G_OBJECT (settings),
- "user-agent", "Mozilla/5.0 (GNOME; not Android) "
- "AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile",
- NULL);
- }
- int
- main(int argc, char *argv[])
- {
- GtkWidget *main_window;
- GtkWidget *scrolled_window;
- GtkWidget *web_view;
- gtk_init (&argc, &argv);
- /* Create the widgets */
- main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- web_view = webkit_web_view_new ();
- /* Place the WebKitWebView in the GtkScrolledWindow */
- gtk_container_add (GTK_CONTAINER (scrolled_window), web_view);
- gtk_container_add (GTK_CONTAINER (main_window), scrolled_window);
- /* Use mobile user agent */
- set_fake_mobile (WEBKIT_WEB_VIEW (web_view));
- /* Open a webpage */
- webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), "https://es.foursquare.com/oauth2/authenticate?response_type=token&client_id=MBNU2NES5HASNDQJ25YPFGG2UGRZHPI3IYTNJGE0KIWT2HCF&redirect_uri=https%3A%2F%2Flocalhost%2F");
- /* Show the result */
- g_signal_connect (main_window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
- gtk_window_set_default_size (GTK_WINDOW (main_window), 800, 600);
- gtk_widget_show_all (main_window);
- gtk_main ();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment