Hi. I beg your forgiveness for my English.
Purpose : send a message (text, picture, download link) to facebook wall from the app.
Problem: The message is not sent.
Details: Create an application with 4 buttons (1 - send the text, 2 - send the picture, 3 - Text and image 4 - Text and link) and created two accounts (developer account and a simple account).
Pressing the first button a message is sent to the developer accounts independently from what I logged on account.
Project:
main.lua:
local W = display.contentWidth; local H = display.contentHeight; local rect1 = display.newRect(0, 0, display.contentWidth, display.contentHeight); --[[local btnFB = display.newImage("f1.png"); btnFB.x = display.contentWidth / 2; btnFB.y = display.contentHeight / 2; local btn = display.newImage("f2.png"); btn.isVisible = false; btn.x = btnFB.x; btn.y = btnFB.y;]]-- local bt1 = display.newImage("bt1.png"); bt1.x = W/2; bt1.y = (H/4)/2; local bt2 = display.newImage("bt2.png"); bt2.x = W/2; bt2.y = H/4 + (H/4)/2; local bt3 = display.newImage("bt3.png"); bt3.x = W/2; bt3.y = H/2 + (H/4)/2; local bt4 = display.newImage("bt4.png"); bt4.x = W/2; bt4.y = H - H/4/2; local appID = "1409374992622806"; local facebook = require( "facebook" ) --local GGFacebook = require( "GGFacebook" ) local json = require( "json" ) local function listener( event ) print( "event.name", event.name ) --"fbconnect" print( "event.type:", event.type ) --type is either "session", "request", or "dialog" print( "isError: " .. tostring( event.isError ) ) print( "didComplete: " .. tostring( event.didComplete ) ) --"session" events cover various login/logout events --"request" events handle calls to various Graph API calls --"dialog" events are standard popup boxes that can be displayed if ( "session" == event.type ) then --options are: "login", "loginFailed", "loginCancelled", or "logout" if ( "login" == event.phase ) then local access\_token = event.token --code for tasks following a successful login end elseif ( "request" == event.type ) then print("facebook request") if ( not event.isError ) then local response = json.decode( event.response ) --process response data here end elseif ( "dialog" == event.type ) then print( "dialog", event.response ) --handle dialog results here end end --[[local function listener1( event ) if ( "session" == event.type ) then if ( "login" == event.phase ) then facebook.request( "me/friends" ); end; elseif ( "request" == event.type ) then local response = event.response print( response ); end; end;]]-- function SendText (event) if event.phase == "began" then bt1.alpha = 0.5; end; if event.phase == "ended" then bt1.alpha = 1; facebook.login( appID, listener, { "publish\_actions, email" } ) local attachment = { message = "Corona Icon file", } facebook.request( "me/feed", "POST", attachment ) facebook.logout() --facebook.request( "me/feed", "POST", { message="SendText"} ) end; end; function SendImage (event) if event.phase == "began" then bt2.alpha = 0.5; end; if event.phase == "ended" then bt2.alpha = 1; facebook.login( appID, listener, { "publish\_actions, email" } ) local attachment = { source = { baseDir=system.DocumentsDirectory, filename="coronaIcon.png", type="image" }, } facebook.request( "me/photos", "POST", attachment ) facebook.logout() end; end; function SendText\_Image (event) if event.phase == "began" then bt3.alpha = 0.5; end; if event.phase == "ended" then bt3.alpha = 1; facebook.login( appID, listener, { "publish\_actions, email" } ) local attachment = { message = "Corona Icon file", source = { baseDir=system.DocumentsDirectory, filename="coronaIcon.png", type="image" }, } facebook.request( "me/photos", "POST", attachment ) facebook.logout() end; end; function SendLink (event) if event.phase == "began" then bt4.alpha = 0.5; end; if event.phase == "ended" then bt4.alpha = 1; facebook.login( appID, listener, { "publish\_actions, email" } ) facebook.request( "me/feed", "POST", {message = "I try send link: ", link = "http://vk.com/project\_noname"} ) facebook.logout() end; end; bt1:addEventListener("touch", SendText); bt2:addEventListener("touch", SendImage); bt3:addEventListener("touch", SendText\_Image); bt4:addEventListener("touch", SendLink);
build.settings:
-- Supported values for orientation: -- portrait, portraitUpsideDown, landscapeLeft, landscapeRight settings = { orientation = { default = "portrait", supported = { "portrait", } }, --[[plugins = { --key is the name passed to Lua's 'require()' ["CoronaProvider.native.popup.social"] = { --required publisherId = "com.coronalabs", }, },]]-- iphone = { plist = { UIStatusBarHidden = false, UIPrerenderedIcon = true, -- set to false for "shine" overlay --UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend --[[-- iOS app URL schemes: CFBundleURLTypes = { { CFBundleURLSchemes = { "fb1409374992622806, -- example scheme for facebook "coronasdkapp", -- example second scheme } } }]]-- } }, -- -- Android permissions androidPermissions = { "android.permission.INTERNET", }, -- }
My settings on Facebook:
Getting the key and the package:
Please, help me…