facebookpostfeed.qml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
  2. import QtQuick 1.1
  3. import QtWebKit 1.0
  4. import SocialConnect 1.0
  5. Rectangle {
  6. width: 800
  7. height: 500
  8. id: main
  9. MouseArea {
  10. anchors.fill: parent
  11. onClicked: Qt.quit();
  12. }
  13. Component.onCompleted: {
  14. facebookConnection.restoreCredentials();
  15. if (!facebookConnection.authenticated) {
  16. facebookConnection.authenticate();
  17. }
  18. }
  19. FacebookConnection {
  20. id: facebookConnection
  21. webInterface: webInterface
  22. permissions: ["publish_stream", "read_stream", "friends_status"]
  23. clientId: "399096860123557"
  24. onAuthenticateCompleted: {
  25. console.debug("Auth: " + success);
  26. if (success) {
  27. facebookConnection.storeCredentials();
  28. proceed();
  29. }
  30. }
  31. }
  32. WebInterface {
  33. id: webInterface
  34. onUrlChanged: webView.url = url;
  35. }
  36. WebView {
  37. id: webView
  38. anchors.fill: parent
  39. preferredHeight: height
  40. preferredWidth: width
  41. onUrlChanged: webInterface.url = url;
  42. }
  43. function proceed() {
  44. if (!facebookConnection.busy) {
  45. webView.opacity = 0;
  46. facebookConnection.postMessage({"text" : "Hello world!"});
  47. }
  48. }
  49. }