Facebook Photo Uploading not working with fb app

Facebook photo uploading is not working when Fb app is already installed in the phone,its working fine when FB app is not installed in the phone as it calls the browser. i have posted my code please help me to resolve this issue

local facebook = require “facebook”
 
– You must use your own app id for this sample to work
local fbAppID = “123456789” --fake

local group=display.newGroup()
local img=display.newImageRect(group,“splash.png”,207/2,310/2)
img.x=display.contentCenterX;img.y=display.contentCenterY

baseDir=system.DocumentsDirectory

function share(event)
    
     function saveimage()
          display.save(group,“shareimg.jpg”)
     end
    timer.performWithDelay(500,saveimage)

local function onLoginSuccess()
– Upload ‘iheartcorona.jpg’ to current user’s account

local attachment = {
message = “First image sharing in fb”,
source = { baseDir=system.DocumentsDirectory, filename=“shareimg.jpg”, type=“image” }
}

facebook.request( “me/photos”, “POST”, attachment )
end
 
– facebook listener
local function fbListener( event )
    if event.isError then
          native.showAlert( “ERROR”, event.response, { “OK” } )
    else

     if event.type == “session” and event.phase == “login” then
– login was a success; call functions
      onLoginSuccess()

      elseif event.type == “request” then

– this block is executed upon successful facebook.request() call
 
         native.showAlert( “Success”, “The photo has been uploaded.”, { “OK” } )

      end
  end
end
 
– photo uploading requires the “publish_stream” permission
     facebook.login( fbAppID, fbListener, { “publish_stream” } )
end

img:addEventListener(“touch”,share)

You need to create keystore file and its keyhash.

Enter keyhash value in your Facebook developer site.

Also create android build using this keystore. and it will work fine for you.

Best Regards,

Team, SP Technolab

www.sptechnolab.com

Thank you SP Technolabfor your reply

How to create keystore file. i already have hash key entered in the facebook developer page

 it uploads image when facebook app is not installed in phone.but with app it doesnt

Step for generating keystone when native Facebook app install in device.

 

in this APP_NAME = your app name.

 

  1. In the terminal, move to the directory where you want to store your keystore file. Then create a new keystore for your application like this: ( where APP_NAME is your app’s name with no spaces)

 

sudo keytool -genkey -v -keystore APP_NAME.keystore - alias APP_NAME_key -keyalg RSA -validity 999999

 

You will first be asked to enter YOUR USER PASSWORD. Then during the key generation process you’ll be asked for a new keystore password, remember it! You’re going to need it in the following steps.

 

  1. Once the keystore is generated you can now export the keyhash that you’ll need to give to Facebook.

 

keytool -exportcert - alias APP_NAME_key -keystore APP_NAME.keystore | openssl sha1 -binary | openssl base64

 

You’ll need to enter the same password that you entered for your keystore. This command will spit out a long string, this is your key hash.

 

  1. Now you can log in to the Facebook developer console at http://developers.facebook.com and paste the key hash into the ‘Key Hashes’ box in the Native Android App section of the app settings.

 

 

Build android build using this keystore file.

 

Best Regards,

Team, SP Technolab

www.sptechnolab.com

Thanks 

It is same in windows too?im using windows right now

For Window you have to remove sudo keyword.

Best Regards,

Team, SP Technolab

www.sptechnolab.com

You need to create keystore file and its keyhash.

Enter keyhash value in your Facebook developer site.

Also create android build using this keystore. and it will work fine for you.

Best Regards,

Team, SP Technolab

www.sptechnolab.com

Thank you SP Technolabfor your reply

How to create keystore file. i already have hash key entered in the facebook developer page

 it uploads image when facebook app is not installed in phone.but with app it doesnt

Step for generating keystone when native Facebook app install in device.

 

in this APP_NAME = your app name.

 

  1. In the terminal, move to the directory where you want to store your keystore file. Then create a new keystore for your application like this: ( where APP_NAME is your app’s name with no spaces)

 

sudo keytool -genkey -v -keystore APP_NAME.keystore - alias APP_NAME_key -keyalg RSA -validity 999999

 

You will first be asked to enter YOUR USER PASSWORD. Then during the key generation process you’ll be asked for a new keystore password, remember it! You’re going to need it in the following steps.

 

  1. Once the keystore is generated you can now export the keyhash that you’ll need to give to Facebook.

 

keytool -exportcert - alias APP_NAME_key -keystore APP_NAME.keystore | openssl sha1 -binary | openssl base64

 

You’ll need to enter the same password that you entered for your keystore. This command will spit out a long string, this is your key hash.

 

  1. Now you can log in to the Facebook developer console at http://developers.facebook.com and paste the key hash into the ‘Key Hashes’ box in the Native Android App section of the app settings.

 

 

Build android build using this keystore file.

 

Best Regards,

Team, SP Technolab

www.sptechnolab.com

Thanks 

It is same in windows too?im using windows right now

For Window you have to remove sudo keyword.

Best Regards,

Team, SP Technolab

www.sptechnolab.com