Posting an image on facebook not working

I am trying to upload an image on facebook. Using this code

      private void getFb()
    {

        final SharedPreferences mPrefs = getSharedPreferences(
                "fbPref", Activity.MODE_PRIVATE);

        String access_token = mPrefs.getString("access_token", null);
        long expires = mPrefs.getLong("access_expires", 0);
        if(access_token != null) {
            fb.setAccessToken(access_token);
        }
        if(expires != 0) {
            fb.setAccessExpires(expires);
        }

        if(!fb.isSessionValid()) 
        {
            fb.authorize(this, new String[] {"publish_stream"}, new DialogListener() {
                public void onComplete(Bundle values) {
                    SharedPreferences.Editor editor = mPrefs.edit();
                    editor.putString("access_token", fb.getAccessToken());
                    editor.putLong("access_expires", fb.getAccessExpires());
                    editor.commit();
                }

                public void onFacebookError(FacebookError error) {}

                public void onError(DialogError e) {}

                public void onCancel() {}
            });
        }

    }



    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        fb.authorizeCallback(requestCode, resultCode, data);

        Bundle parameters = new Bundle();
  //      parameters.putString(Facebook.TOKEN, fb.getAccessToken());
        // The byte array is the data of a picture.
        parameters.putString("message", "LolCats Test");
parameters.putString("picture", "http://cdn3.f-cdn.com/ppic/514992/logo/597178/profile_logo_597178.jpg");
parameters.putString("caption", "LLoll casts");

        try {
            fb.request("me/photos", parameters, "POST");

        } catch (FileNotFoundException fileNotFoundException) {
           // makeToast(fileNotFoundException.getMessage());
        } catch (MalformedURLException malformedURLException) {
          //  makeToast(malformedURLException.getMessage());
        } catch (IOException ioException) {
         //   makeToast(ioException.getMessage());
        }

    }

The only thing that happens is a page with FB app opens , do some progress bar and then back to the application, no error etc. What is wrong with image not getting shared on facebook?

Answers


Please try this.

parameters.putString("message", "LolCats Test");
parameters.putByteArray("source", "http://cdn3.fcdn.com/ppic/514992/logo/597178/profile_logo_597178.jpg".getBytes());

Need Your Help

Auto-associate a Credit Memo with an Invoice when creating a QuickBooks IIF File

import quickbooks iif invoices

We have a system built that exports invoices to an IIF file format so the client can import the invoices and all the invoice line items into QuickBooks.

Backbone: dynamic views hierarchy with templates

templates backbone.js views

I have three different view templates: "post", "comment", "add new comment". The main template is "post". I need to find out how to place "comments" and "add new comment" templates into theyr divs ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.