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.
Related
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);
I am getting "ActionDispatch::Request::Session:0xa8fde64 not yet loaded" when try to access the session in application controller.
It gives error when try to access rails application on iphone.
It's working properly on desktops browsers.
After login it goes to index page and I added before filter "admin_authenticate" for index page.
my sessioncontrollerfile
class AdminSessionController < ApplicationController
def create
if (params[:username] == 'abc#abc.com' and params[:password] == '12345')
session[:admin_id] = 1
redirect_to admins_path, :notice => "Login Ok"
end
end
my applicationcontoller file
class ApplicationController < ActionController::Base
def admin_authenticate
if session[:admin_id] == 1
return true
else
redirect_to "/login"
end
end
end
Not able to access session value set in AdminSessionController inside admin_authenticate method of application controller.
This issue is solved.
By default cookies are disabled in iOS-7, if you enable the cookies you can access the sessions.
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......... :)
I'm having a strange problem when trying to set a callback for Facebook Authentication via Omniauth. In my controller (simplified to just the code necessary to show the error) I have:
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
raise env.inspect
# auth_hash = env["omniauth.auth"]
end
end
this works in production mode, showing me the hash. However in test mode env is set to nil.
I have the following set in my spec_helper.rb file
OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(:facebook, {"credentials" => {
"token" => "foo-token"
}
})
and my spec looks like this:
require 'spec_helper'
describe Users::OmniauthCallbacksController do
describe "Facebook" do
before(:each) do
request.env["devise.mapping"] = Devise.mappings[:user]
request.env["omniauth.auth"] = OmniAuth.config.mock_auth[:facebook]
end
it "should be a redirect" do
get :facebook
response.should redirect_to(root_path)
end
end
end
Can anyone enlighten me on what I need to do to have env not be nil when running my tests?
I use the following in my spec_helper.rb :
RACK_ENV = ENV['ENVIRONMENT'] ||= 'test'
I don't use Rails or Devise though so YMMV. I've also seen various threads saying that someone had to do this before their requires to get it to work.
So I have a rails app 2.x app that works fine via the web, but when trying to perform a POST I keep getting "Redirected to http://localhost:3000/session/new Filter chain halted as [:require_user] rendered_or_redirected.". In my iPhone app, I can create a new session and sign-in via my iPhone app, but cannot POST to say the POSTS_Controller.
I have this in my code
Posts_Controller
before_filter :require_user, :only => [:create, :update, :destroy]
Application_Controller
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
include AuthenticatedSystem
include Geokit::Geocoders
helper :all # include all helpers, all the time
#session :session_key => '_cwa_session_id'
#filter_parameter_logging :password
# See ActionController::RequestForgeryProtection for details
# Uncomment the :secret if you're not using the cookie session store
protect_from_forgery # :secret => 'eejj7eded74769099999944a729b4f'
#filter_parameter_logging(:password)
before_filter :login_from_cookie
before_filter :find_user_interests
before_filter :find_user_posts
protected
def find_user_interests
#user_interests = cur_user ? cur_user.interesting_posts : []
logger.debug "User interests hash: #{current_user.inspect}"
end
def find_user_posts
#user_posts = cur_user ? cur_user.posts : []
end
def cur_user
User.find(session[:user_id]) if session[:user_id]
end
def require_user
unless cur_user
flash[:error] = "You must be logged in to do that."
redirect_to '/session/new'
return false
end
end
geocode_ip_address
def geokit
#location = session[:geo_location]
end
end
I have been working on this for 2 months and cannot figure out the issue. In my iPhone app I am using ObjectiveResource. I am sending over json and have "Mime::Type.register_alias "application/json", :json" set up on the rails side.
I am not a rails developer, but the before filter for require_user is unable to pass the cur_user test in that is cannot find :user_id in the session hash. Are you sure that you have a session that persists when using the iPhone? Are you using devise for authentication? Just for kicks, does it work if you manually pass the user_id as params?