×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    279

    Update facebook wall through qml application ??

    Hi,
    I had searched more on this forum and others to get a solution for sharing or updating my wall status on facebook through my application but i didn't get any working code ??!!.
    please Nokia experts tell me how to do this if it is possible or refer me to a working link
    many thanks
    Ram

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Update facebook wall through qml application ??

    Hello ram4soft

    Yes ofcourse its possible with Facebook OAuth v2 and QML Webview its quite easy to post or call any facebook api using the javascript or traditional c++. Please have a look at this article http://www.johanpaul.com/blog/2011/0...with-qt-quick/ which can be a good one to start with.

  3. #3
    Registered User
    Join Date
    May 2009
    Location
    Greece
    Posts
    191

    Re: Update facebook wall through qml application ??

    Also the following project is very helpful: https://projects.developer.nokia.com/kasvopus

    More specifically look this script: https://projects.developer.nokia.com...js/facebook.js
    The function "doWebRequest" will enable you to submit Http Requests. To do this, you must be first logged in (also included in that project).

    The script uses the Facebook's Graph API. Its documentation can be found here and i have to admit that it's quite easy to use: http://developers.facebook.com/docs/reference/api/

    Also Facebook has a tool to quick check the API called Graph API Explorer: http://developers.facebook.com/tools/explorer. In there once logged in with your facebook account you can test the API.

    For instance, to post the message on your Wall you submit a POST request with the following: https://graph.facebook.com/me/feed/?message=TestFeed
    If you want to post to someone else Wall you just change the word "me", with the id of the contact that has that Wall.

    Last edited by favoritas37; 2011-10-31 at 09:19.

  4. #4
    Registered User
    Join Date
    Jul 2007
    Posts
    279

    Re: Update facebook wall through qml application ??

    thanks for reply,
    i tried the Oauth example but i still can't share a status on my wall that is all what i wanted.
    I can do this simply on twitter by writing this http://twitter.com/home?status=my new status.
    For instance, to post the message on your Wall you submit a POST request with the following: https://graph.facebook.com/me/feed/?message=TestFeed
    it needs access token
    please try to help
    thanks

  5. #5
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Update facebook wall through qml application ??

    hello ram4soft,

    yes indeed its correct, first you need to authenticate your application and with that you will get an access token which you need to use for making the api calls which is the second step.

    So are you doing the first step of authentication properly.

  6. #6
    Registered User
    Join Date
    Jul 2007
    Posts
    279

    Re: Update facebook wall through qml application ??

    Hello gaba,
    yes i did and i got an client_id and secret key

  7. #7
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Update facebook wall through qml application ??

    hello ram4soft

    i am not talking of the client id and the secret key, using those too, you need to show an authentication dialog which will get you the access token required for making api calls.

  8. #8
    Registered User
    Join Date
    May 2009
    Location
    Greece
    Posts
    191

    Re: Update facebook wall through qml application ??

    You will easily acquire the access token by calling function: getAccessToken(code) in the https://projects.developer.nokia.com...js/facebook.js posted above. This function will produce a authentication screen where the user will allow the needed access tokens.

    Be careful not to forget to replace the client id and client secret with those of your application.

  9. #9
    Registered User
    Join Date
    Jul 2007
    Posts
    279

    Re: Update facebook wall through qml application ??

    hello fav.
    I called that function but there was no way to get the code which i send to the accesstoken function.also i used this url: "https://www.facebook.com/dialog/oauth?client_id=201537833255643&redirect_uri=http://www.facebook.com/connect/login_success.html&response_type=token&scope=publish_stream,read_stream"
    in my webview to authenticate the user and it is logging on but the problem now is to get the authenticated code which used to get the access token
    thanks

  10. #10
    Registered User
    Join Date
    May 2009
    Location
    Rome
    Posts
    268

    Re: Update facebook wall through qml application ??

    i use this code to extract the token
    you can easily adapt it to your case .

    As the token is passed in the hash (#)
    i found it easy to replace # with ? and then use url.queryItemValue to extract token

    bool FacebookGraph::isAuthUrl(QString u){
    if (u.startsWith("http://www.facebook.com/connect/login_success.html")){
    QUrl url=u.replace("#","?");
    token=url.queryItemValue("access_token");
    error=url.queryItemValue("error_reason");
    qDebug()<<"access_token"<<token;
    qDebug()<<"error_reason"<<error;
    }
    }
    Keep it simple, stupid
    borg - http://store.ovi.com/content/116105

  11. #11
    Registered User
    Join Date
    May 2009
    Location
    Greece
    Posts
    191

    Re: Update facebook wall through qml application ??

    Use this exact code: https://projects.developer.nokia.com...oginDialog.qml

    At the function "onLoadFinished:" you will add the following:
    Code:
     onLoadFinished: {
                    var urlStr = webView.url.toString();
                    var token_re= "access_token=(.*)&expires_in="
    
                    if(urlStr.indexOf("access_token") != -1)
                    {
                        //console.log("accessToken: " + urlStr.match(token_re)[1]);
                    }
                }

  12. #12
    Registered User
    Join Date
    Jul 2007
    Posts
    279

    Re: Update facebook wall through qml application ??

    Thanks guys for your support
    here is my code
    Code:
    WebView {
                id: webView
                anchors.fill: parent
                preferredHeight: height
                preferredWidth: Math.max(parent.width,640)
                url: "https://www.facebook.com/dialog/oauth?client_id=201537833255643&redirect_uri=https://www.facebook.com/connect/login_success.html&scope=publish_stream,offline_access,read_stream,user_status,user_photos,friends_photos,friends_status,user_checkins,friends_checkins,user_events"; //&display=touch";
                onLoadFinished: {
                    var urlStr = webView.url.toString();
                    console.log("Neww Url: "+urlStr)
                    var token_re= "access_token=(.*)&expires_in="
                    if(urlStr.indexOf("login_success.html?code=")!= -1)
                    {
                        var code = urlStr.match("code=(.*)")
                        console.log("The code ="+code);
                        webView.url = "https://graph.facebook.com/oauth/access_token?client_id=201537833255643&client_secret=cdd0687d24ee41d5b98410bfd2c60ca5&" + code + "&redirect_uri=https://www.facebook.com/connect/login_success.html";
                    }
    
                   if(urlStr.indexOf("access_token") != -1)
                   {
                       console.log("last Url:"+urlStr) 
                       // console.log("the accessToken: " + urlStr.match(token_re)[1]);
    
                      // FBMngr.postStatus(urlStr.match(token_re)[1],"matchat share")
                   }
                 }
    
                onLoadFailed: {
                    loginDialog.loadFailed();
                }
    
            }
    now i can login and get the auth code for getting the access token.
    when i try to get accesstoken i got this page
    Code:
    {
       "error": {
          "message": "Missing redirect_uri parameter.",
          "type": "OAuthException"
       }
    }
    ,
    this is the final url after adding the code url

    where is the problem?
    thanks

  13. #13
    Registered User
    Join Date
    May 2009
    Location
    Greece
    Posts
    191

    Re: Update facebook wall through qml application ??

    I don't think it is needed to create a specific request for the access token to get it. Normally the access token is eitherway returned at a URL after the successful authentication, so you only need to listen for the new URLs and get it.

    So in my case i didn't put the following lines of yours
    Code:
    if(urlStr.indexOf("login_success.html?code=")!= -1)
                    {
                        var code = urlStr.match("code=(.*)")
                        console.log("The code ="+code);
                        webView.url = "https://graph.facebook.com/oauth/access_token?client_id=201537833255643&client_secret=cdd0687d24ee41d5b98410bfd2c60ca5&" + code + "&redirect_uri=https://www.facebook.com/connect/login_success.html";
                    }
    Try removing them and see what happens.

  14. #14
    Registered User
    Join Date
    Jul 2007
    Posts
    279

    Re: Update facebook wall through qml application ??

    thank fav,
    I did another way after i got the code i used the facebook.js functions as follows
    Code:
    if(urlStr.indexOf("login_success.html?code=")!= -1)
                    {
                        var code = urlStr.match("code=(.*)")
                        console.log("The code ="+code);
                        FBMngr.getAccessToken(code);
    it gave be Error: Facebook API returned 400 Bad Request

  15. #15
    Registered User
    Join Date
    May 2009
    Location
    Greece
    Posts
    191

    Re: Update facebook wall through qml application ??

    Just saw that you didn't put "response_type=token" to your URL.

    So change it into:
    Code:
    url: "https://www.facebook.com/dialog/oauth?client_id=201537833255643&redirect_uri=https://www.facebook.com/connect/login_success.html&scope=publish_stream,offline_access,read_stream,user_status,user_photos,friends_photos,friends_status,user_checkins,friends_checkins,user_events&response_type=token";

Page 1 of 2 12 LastLast

Similar Threads

  1. Post Highest Score on Facebook Wall
    By elminator in forum [Archived] Flash Lite on Nokia Devices
    Replies: 3
    Last Post: 2011-03-16, 08:55
  2. How to integrat facebook api with my application ?
    By prashant.sharma in forum Symbian C++
    Replies: 1
    Last Post: 2010-12-21, 12:03
  3. Facebook Status update with login authentication
    By amitccet in forum Symbian Web Runtime
    Replies: 1
    Last Post: 2010-05-31, 16:01
  4. How to add Facebook to my Application.
    By rapelly.srinu in forum Symbian C++
    Replies: 7
    Last Post: 2009-09-06, 13:03
  5. Snake through the wall!
    By risto.mononen in forum Python
    Replies: 0
    Last Post: 2007-04-05, 19:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •