SA
I have a application written in RubyonRails and I want to make him post periodically on facebook fan page.
I used fb_graph gem to do that.
I created my facebook app and I get my Access Token to use it but when I use this peace of code
me = FbGraph::User.me(ACCESS_TOKEN)
me.feed!(
:message => 'Updating via FbGraph',
:picture => 'https://graph.facebook.com/matake/picture',
:link => 'http://github.com/nov/fb_graph',
:name => 'FbGraph',
:description => 'A Ruby wrapper for Facebook Graph API'
)
I get permission denied error message.
How can I get the permission to post on my fan page wall?
Thanks in advance.
Link to the docs:
http://developers.facebook.com/docs/authentication/
There are several flows, but essentially, you provide a link for the client to authenticate at facebook:
https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&scope=publish_stream,manage_pages
After authing this redirects to a URL on your site prepared to handle the param code, which you then turn around and send back to facebook for your access_token, which you provide to fb_graph.
https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&redirect_uri=YOUR_URLclient_secret=YOUR_APP_SECRET&code=CODE
There are other permissions as well, so you might want to check the facebook docs to see if there are more you need.
Facebook uses OAuth 2 for auth, and there are several ruby gems you can use to facilitate this process slightly, including the oauth2 gem.
The app ID you specified must be wrong. please cross check that. A sample appID looks like this
APP_ID="162221007183726"
Also check whether you have used any call back url. The url should point to a server. Your cannot use your localhost/ local IP there.
A similar nice rails plugin for Facebook app using Rails3 is Koala gem
https://github.com/arsduo/koala/wiki/Koala-on-Rails
http://blog.twoalex.com/2010/05/03/introducing-koala-a-new-gem-for-facebooks-new-graph-api/
Related
I am making a simple app in Ruby I need to get User's Email. I am using Google API client for Ruby. I am not able to get User's Email address, I have been researching on this topic for 2 days, and not able to get Email of user after the user sign in. I dont want to do it with Google+ sign in button I want it programmatically. I get authorized by google but then dont know how to retrieve the User Info of signed in user. I tried also tried it with client = Google::APIClient.new but i was not able. Below is my Code. I will appreciate your help.
scopes = ['https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/calendar.readonly', 'https://www.googleapis.com/auth/plus.login','https://www.googleapis.com/auth/userinfo.email']
client_secrets = Google::APIClient::ClientSecrets.load(SECRETS_PATH)
auth_client = client_secrets.to_authorization
auth_client.update!(
:additional_parameters => {"access_type" => "offline"}
)
auth_client.update!(
:scope => scopes,
:redirect_uri => 'http://localhost:3000/google_oauth2')
Hey On this You can Refer the Gem Google Plus
I have implemented the same and It's Working Fine from these sides.
Steps to Integrate Following Gem-
Firstly Install the google_plus gem by including it on GemFile.
Generate the API Key from Google Console of Google Plus +
https://console.developers.google.com
Including it Before use like it
GooglePlus.api_key = 'your key'
Search any Person by Id of Google
person = GooglePlus::Person.get(123)
You will get the complete users info for particular users
I know that there is Koala gem for Rails to work with Facebook. I need to make clear 2 things:
How to check if some access_token is valid in Rails using Koala (or something else)?
How to generate some real access token (using some settings of my app or my login/password) for testing through RSpec?
Thanks in advance.
For #1 Use the Tool https://developers.facebook.com/tools/debug if you don't want to code a test. Otherwise hit this API and verify the response.
https://graph.facebook.com/oauth/access_token_info?client_id={APP_ID}&access_token={ACCESS_TOKEN}
For #2, Koala has a good API for accessing Facebook Test Users, which I recommend for use in Rspec.
We also support the test users API, allowing you to conjure up fake
users and command them to do your bidding using the Graph or REST API:
#test_users = Koala::Facebook::TestUsers.new(:app_id => id, :secret => secret)
user = #test_users.create(is_app_installed, desired_permissions)
user_graph_api = Koala::Facebook::API.new(user["access_token"])
# or, if you want to make a whole community:
#test_users.create_network(network_size, is_app_installed, common_permissions)
You can also create Test User in the App Settings from Facebook, and view thier details from this API :
https://graph.facebook.com/{APP_ID}/accounts/test-users?%20access_token={APP_TOKEN}
I want to get PayPal reports and for this reason I installed paypal-report gem.
Can someone look are my credentials are correct or for Reporting API usage I need some special account ?
I have verified bussiness account.
Here is my code:
require 'paypal/report'
api = Paypal::Report.new("my secure account MerchantID", "mypassword", "my secure account MerchantID", "PayPalUK")
puts api.daily.inspect
I also tried to enter my email instead of MerchanID, but it didn't work.
and this gives me error:
C:/Ruby193/lib/ruby/gems/1.9.1/gems/paypal-report-0.1.2/lib/paypal/report.rb:141
:in `block in request': Invalid merchant account (RuntimeError)
I tried to inspect api value, by using puts api and here is result:
puts api
//and result:
#<Paypal::Report:0x27a4310>
Can someone help me ?
Seeing 'PayPalUK' in there, I've got a suspicion the gem you're using is for PayPal Payflow services (and when it comes to reporting, that would be XML Reporting).
Seeing as you mention having a regular 'verified business account', I don't think you'd have access to Payflow API calls. Thus, no correct credentials to enter there.
What PayPal API call are you trying to use? Is it TransactionSearch you're looking for?
If so, try the ruby-paypal gem.
(Note, I haven't tested it, but it's the first one a quick Google search for "PayPal TransactionSearch gem" returned.)
I am using Omni auth gem to load twitter feeds into my application.
But when i try to load direct messages, its not letting the application to direct messages.
I researched and found that when adding a twitter account, usually the system takes us to
https://api.twitter.com/oauth/authenticate
but i found my applicatin could access direct message when the request made to twitter during twitter account add process will be like below
https://api.twitter.com/oauth/authorize
where do i configure this in Omniauth gem?
Please give me a hand on this.
thanks.
This can be done by adding client_options: {authorize_path: '/oauth/authorize'}
under config/initializers/omniauth.rb under provider :twitter.
I am currently trying to use this gem http://github.com/pengwynn/linkedin. Everything works fine (i.e. authentication and calling the method which gets the profile), except that the profile object only contains the first name and the last name.
I'm trying to get my own profile info through the LinkedIn API, So the necessary information is there. How to do that?
Thank you.
I just found out that in order to get more info rather that first name and last name, one needs to pass in the :fields param specifying the desired fields.
Link LinkedIn into your next Ruby application
Example from the site:
# get a profile for someone found in network via ID
client.profile(:id => 'gNma67_AdI', :fields => %w(first-name, last-name, headline, positions, education))
By design, the LinkedIn api does not give you the person's email address. (Unlike the Google oauth api).
What you can get from the LinkedIn api is information about the person's connections (friends) and more. See overview. Their profile api
Added: could be that the Rails LinkedIn gem does not yet expose all of the LinkedIn Profle api. That api has changed relatively recently. It may be that you'll need to find another gem or write you own sw to do it. Check on the LinkedIn api forum