Share an app with Friends with Corona sdk free version - facebook

I am trying to share my app created in corona sdk free version in facebook. But no working example found on internet. It seems there is a change in facebook api or policy. Does any one have created app in corona sdk with facebook integration recently ? Can any one provide me referece to the way we can integrate the facebook.
I found another question sharing my app through facebook in corona Sdk but the link provided in answer is down. It would be greate= help.
Is there any update in facebook API ? as I am getting response null every time. can any one provide working example reference created recently ?
I tried the example provided by krs in following answer but it is not working for me.
https://developer.coronalabs.com/content/facebook
when I click on any of the feature like post Msg it goes to facebook page and after some processing it directly comes to the home page again nothing gets done. In log I ma getting response null.
following is screenshot of error.
any help will be great help to me.
EDIT
I had tried a lot but the same issue is there. I think facebook app configuration problem is there.
Can anyone provide detailed step by step information to configure an app and generate build in corona ? I am giving another 100 point bounty for this.

I hope this helps make a lua file and copy this code name it whatever you want
local facebook = require "facebook"
local json = require "json"
local _M = {}
local appId = "" -- put your app id string here
local message = ""
local access_token = ""
local fbCommand = ""
local LOGOUT = 1
local SHOW_DIALOG = 2
local POST_MSG = 3
local POST_PHOTO = 4
local GET_USER_INFO = 5
local GET_PLATFORM_INFO = 6
function showPopup(popupTitle,popupMessage)
native.showAlert( popupTitle, popupMessage, {"OK"} )
end
function listener( event )
if ( "session" == event.type ) then
if ( "login" ~= event.phase ) then
showPopup("Facebook share score failed!", "Please try again")
return
end
print(access_token)
access_token = event.token
if fbCommand == GET_USER_INFO then
facebook.request("me")
elseif fbCommand == POST_MSG then
facebook.request("me/feed", "POST" , {message = message} )
end
elseif ( "request" == event.type ) then
local response = event.response
print("Response: ",response)
if ( not event.isError ) then
if fbCommand == GET_USER_INFO then
response = json.decode( event.response )
elseif fbCommand == POST_MSG then
showPopup("Facebook share score", "You've successfully shared your score!")
end
else
showPopup("Facebook share score failed!", "Please try again")
end
end
end
function _M:postToWall(msg)
message = msg
fbCommand = POST_MSG
facebook.login( appId, listener, {"publish_stream"} )
end
function _M:shareGame()
message = "Juggler http://google.com/"
fbCommand = POST_MSG
facebook.login( appId, listener, {"publish_stream"} )
end
return _M
and when you want to share on use this function
local function FacebookShare(event)
if event.phase == "began" then
local FBManager
local message
FBManager = require( "Facebook" )
message = "" -- your message
FBManager:postToWall(message)
end
end
if user is not login it will call login facebook.
this works for me hope it solve your problem

There is facebook sample app from ansca labs. See that from the link below:
https://developer.coronalabs.com/content/facebook
And there is an integration in the app Ghosts-vs.-Monsters
https://github.com/ansca/Ghosts-vs.-Monsters
Keep coding......... :)

Related

Connecting to Facebook's API

I am facing this issue connecting with Facebook's API using httr package, while testing on 'me' node I came along the following problem.
I was under the impression that me node does not require special permissions.
Testing on the browser with 'https://graph.facebook.com/me' gave the same results, it would be great if some one could provide an explanation.
# Define keys
app_id = 'my_app_id'
app_secret = 'my_app_secret'
# Define the app
fb_app <- oauth_app(appname = "facebook",
key = app_id,
secret = app_secret)
# Get OAuth user access token
fb_token <- oauth2.0_token(oauth_endpoints("facebook"),
fb_app,
scope = 'public_profile',
type = "application/x-www-form-urlencoded",
cache = TRUE)
response <- GET("https://graph.facebook.com",
path = "/me",
config = config(token = fb_token))
# Show content returned
content(response)
$error
$error$message
[1] "An active access token must be used to query information about the current user."
$error$type
[1] "OAuthException"
$error$code
[1] 2500
$error$fbtrace_id
[1] "ARRnb93rZHmWLlXK_MMJlfi"
Noting that I have signed in using the app.

how can i send facebook message using selenium webdriver

I am able to login on facebook, able to open chat but unable to send any message
Below program code I have used:
//Login on FB >> Working fine
driver.findElement(By.xpath(".//*[#id='email']")).sendKeys("******#gmail.com");
driver.findElement(By.xpath(".//*[#id='pass']")).sendKeys("********");
driver.findElement(By.xpath(".//*[#id='u_0_l']")).click();
// click on message icon >> Working fine
driver.findElement(By.xpath(".//*[#id='u_0_h']/li[1]/div/a/span")).click();
//click on friends name, to whom i want to send message >> Working fine
driver.findElement(By.xpath("/html/body/div[1]/div[1]/div/div/div/div[1]/div/div/div[2]/ul/li[5]/div/div[2]/div/div[3]/div/div[1]/div/div/ul/li[2]/a")).click();
Thread.sleep(5000);
//Send message >>>> here, i am not getting any response, code run without entered any message or error
driver.findElement(By.xpath(".//*[#class='_552h _35li _n4k']")).sendKeys("Hiii");
driver.findElement(By.xpath("/html/body/div/div[5]/div[1]/div/div/div[1]/div/div[1]/div[2]/div/div/div/div/div[4]/div[5]/div[1]/div/div/div[2]/div/div/div")).sendKeys(Keys.ENTER);;
I have used this code, it works for me.
driver.findElement(By.xpath("//div[contains(#class,'_5rpu') and #role='combobox']")).sendKeys("hi"+Keys.ENTER);
require 'selenium-webdriver'
#driver = Selenium::WebDriver.for :chrome
#driver.get 'https://www.facebook.com/fname.lname?fref=none'
a = #driver.find_element(:xpath, '//[#id="email"]').send_keys('aaa#gmail.com')
a = #driver.find_element(:xpath, '//*[#id="pass"]').send_keys('12345678')
a = #driver.find_element(:xpath, '//*[#value="Log In"]').click
sleep 5
a = #driver.find_element(:xpath, '//a[#href="/messages/fname.lname" and #role="button"]').click
sleep 2;p 'This is Where I clicked/initiated the Send Message '
a = #driver.find_element(:xpath, '//div[#class="_1ia"]/descendant::div[#class="_5rpu" and #role="textbox"]')
a.send_keys('Hi There') # This is where I entered the keys and Did Enter
a.send_keys:enter
The correct answer since the #role has changed is :
WebElement sendmsg = driver
.findElement(By.xpath("//div[#class='_1ia']/descendant::div[#class='_5rpu' and #role='combobox']"));
sendmsg.sendKeys("Just testing: using selenium webdriver" + Keys.ENTER);

RubyMotion: Objective-C stub for message `logInWithPermissions:block:' type `v#:##?' not precompiled

I tried to implement a Facebook login via Parse.com iOS SDK.
When I try to use the PFFacebookUtils.loginWithPermissions:block: method, I got the error.
Objective-C stub for message `logInWithPermissions:block:' type `v#:##?' not precompiled. Make sure you properly link with the framework or library that defines this message.
Anyone experienced this?
I use
rubymotion 2.31
Parse-iOS-SDK 1.2.19 (using cocoapods)
This is my Rakefile:
$:.unshift('/Library/RubyMotion/lib')
require 'motion/project/template/ios'
require 'bundler'
Bundler.require
Motion::Project::App.setup do |app|
app.name = 'myapp'
app.identifier = 'com.your_domain_here.myapp'
app.short_version = '0.1.0'
app.version = app.short_version
app.sdk_version = '7.1'
app.deployment_target = '7.0'
app.icons = ["icon#2x.png", "icon-29#2x.png", "icon-40#2x.png", "icon-60#2x.png", "icon-76#2x.png", "icon-512#2x.png"]
app.device_family = [:iphone]
app.interface_orientations = [:portrait]
app.files += Dir.glob(File.join(app.project_dir, 'lib/**/*.rb'))
app.frameworks += [
'Accounts',
'AudioToolbox',
'CFNetwork',
'CoreGraphics',
'CoreLocation',
'MobileCoreServices',
'QuartzCore',
'Security',
'Social',
'StoreKit',
'SystemConfiguration']
app.libs += [
'/usr/lib/libz.dylib',
'/usr/lib/libsqlite3.dylib']
app.pods do
pod 'SVProgressHUD'
pod 'Parse-iOS-SDK'
end
FB_APP_ID = '<my facebookAppId>'
app.info_plist['FacebookAppID'] = FB_APP_ID
app.info_plist['CFBundleURLTypes'] = [{ CFBundleURLSchemes: ["fb#{FB_APP_ID}"] }]
end
Related code:
def login_with_facebook
PFFacebookUtils.logInWithPermissions(['email'],
block: lambda do |user, error|
if !user
puts 'failed!'
elsif user.isNew
puts 'User signed up and logged in through Facebook!'
else
puts 'User logged in through Facebook!'
end
end
)
end
This is a known bug in the way the Parse SDK bridge files are generated:
http://hipbyte.myjetbrains.com/youtrack/issue/RM-119
Workaround here (for me, I had to do the replacement in the vendor/Pods/build-iPhoneSimulator/Pods.bridgesupport file)
https://groups.google.com/forum/#!msg/rubymotion/36WCWPPkPdc/kBCDS-DOSjsJ

PayPalAPIInterfaceServiceService::SetExpressCheckout() returns null response object

I'm using Yii to build an application that requires payments through PayPal. After a lot of digging, I found that ExpressCheckout is the method to use. The code below worked fine some time ago (some (?) weeks ago, I suppose before PayPal rolling out their new developer platform), using version 1.2.95 of the PHP SDK. Now, using the latest version v.2.2.98, the code fails.
require_once(Yii::getPathOfAlias('application.libraries.paypal') . '/PPBootStrap.php');
$logger = new PPLoggingManager('SetExpressCheckout');
$PaymentDetails = new PaymentDetailsType();
$PaymentDetails->OrderTotal = $PaymentDetails->ItemTotal =
new BasicAmountType('USD', $subscription->price);
$PaymentDetails->PaymentAction = "Sale";
$PaymentDetails->OrderDescription = $subscription->description;
$setECReqDetails = new SetExpressCheckoutRequestDetailsType();
$setECReqDetails->PaymentDetails[0] = $PaymentDetails;
$setECReqDetails->CancelURL = 'someCancelUrl';
$setECReqDetails->ReturnURL = 'someReturnUrl';
$setECReqType = new SetExpressCheckoutRequestType();
$setECReqType->SetExpressCheckoutRequestDetails = $setECReqDetails;
$setECReq = new SetExpressCheckoutReq();
$setECReq->SetExpressCheckoutRequest = $setECReqType;
$paypalService = new PayPalAPIInterfaceServiceService();
$ok = TRUE;
try {
$setECResponse = $paypalService->SetExpressCheckout($setECReq);
if($setECResponse && strtoupper($setECResponse->Ack) =='SUCCESS') {
$token = $setECResponse->Token;
// Redirect to paypal.com here
$this->redirect(
'https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=' . $token);
}
}
catch (Exception $ex) {
Yii::trace(__METHOD__ . ': Exception while interacting with PayPal API, error: '
. $ex->getMessage());
$ok = FALSE;
}
The offending line is:
$setECResponse = $paypalService->SetExpressCheckout($setECReq);
In PayPalAPIInterfaceServiceService::SetExpressCheckout(), these two lines:
$resp = $this->call('PayPalAPIAA', 'SetExpressCheckout', $setExpressCheckoutReq, $apiCredential);
$ret->init(PPUtils::xmlToArray($resp));
are the issue. $resp is null, so the next line fails at the PPUtils::xmlToArray($resp) method call.
Obviously, either I'm missing something here, or PayPal does something wrong.
Any help?
After a lot of debugging, the cause of the issue was that the service.EndPoint.PayPalAPI parameter was not defined in sdk_config.ini. For some reason that I don't recall, this parameter was deleted from the working config file from the previous version.
Now, the express checkout method works fine, even with the latest 2.3.100 version of the API.

500 error when calling webservice through rhosync/rhodes

I am trying to call a web service in rhosync application.rb, I see a 500 error response in rhosync console .. and 'server returned an error' in BB simulator .. :(
Some info about my setup -
I have created a rhodes app that connects to a rhosync app when user enters user name and password and clicks on "login". I am calling this webservice through "authenticate" method of application.rb of the rhosync application ..
def authenticate(username,password,session)
Rho::AsyncHttp.get(:url => 'http://mywebserviceURL',:callback => (url_for :action => :httpget_callback),:callback_param => "" )
end
UPDATE
Instead of http:async, I tried consuming a soap based webservice and it worked just fine .. here is code if anyone cones here in search of a sample.. in application.rb of rhosync app
require "soap/rpc/driver"
class Application < Rhosync::Base
class << self
def authenticate(username,password,session)
driver = SOAP::RPC::Driver.new('http://webserviceurl')
driver.add_method('authenticate', 'username', 'password')
ret=driver.authenticate(username,password)
if ret=="Success" then
true
else
false
end
end
end
Application.initializer(ROOT_PATH)
You can typically find the problem if you crank up your log. Edit rhoconfig.txt in your app
set these properties -
# Rhodes runtime properties
MinSeverity = 1
LogToOutput = 1
LogCategories = *
ExcludeLogCategories =
then try again and watch the terminal output. Feel free to post the log back and I'll take a look.
You also might want to echo out puts the mywebserviceURL if you're using that as a variable, I trust you just changed that for the post here. Can you access the webservice if you hit it with a browser?
require "soap/rpc/driver"
class Application < Rhosync::Base
class << self
def authenticate(username,password,session)
driver = SOAP::RPC::Driver.new('http://webserviceurl')
driver.add_method('authenticate', 'username', 'password')
ret=driver.authenticate(username,password)
if ret=="Success" then
true
else
false
end
end
end
Application.initializer(ROOT_PATH)
in this what is done in add_method and authenticate method and where it to be written.