Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
= Facebook API
A simple, lightweight Ruby library for accessing the Facebook REST API. Currently used in Facebook Connect applications, but could easily be extended for use in canvas applications.
== Install
gem install facebook_api
== Usage
require 'facebook_api'
FacebookApi.configure do |config| config.api_key = '55e9919b8c017abe484c9fb336dffb90' config.secret_key 'fc881eb66493e0b845a3528c018cdd56' config.canvas_page_name = 'crowdfm_publisher' config.callback_url = 'http://crowd.fm/' end
session = FacebookApi::Session.new(session_key, uid)
response = session.call('Friends.get', :uid => '12345')
response = session.call('Photos.upload', {:uid => '12345', :aid => '67890', :caption => 'your caption'}, File.new('/path/to/image.jpg))
response = session.call_fql('SELECT page_id FROM page_admin WHERE uid="12345"')
Both FacebookApi::Session#call and FacebookApi::Session#call_fql will generally return a hash, parsed from the JSON returned by Facebook. However, for some API calls Facebook returns non-valid JSON, usually either 'true', 'false' or a string literal (e.g. '12345'). In these cases, the return value from #call and #call_fql will be either true, false or the string literal respectively.
=== How to use in a Rails application
With a couple of simple methods, you can make Facebook sessions available to you in your controllers and views:
class ApplicationController < ActionController::Base # Requiring a valid facebook connect session for your controller actions with a before_filter: before_filter :require_facebook_session, :except => [:login] # Make the facebook_session available in your views by making it a helper_method: helper_method :facebook_session
private
def facebook_session
@facebook_session ||= facebook_session_from_cookies
end
def facebook_session_from_cookies
if FacebookApi.verify_connect_cookies_signature(cookies)
FacebookApi::Session.new(cookies["#{FacebookApi.api_key}_session_key"], cookies["#{FacebookApi.api_key}_user"])
end
end
def require_facebook_session
unless facebook_session
redirect_to facebook_connect_path
end
end
end
== Acknowledgements
Thanks to Mike Mangino of Facebooker and Travis Reeder of MiniFb for inspiration.
== Copyright
Copyright (c) 2010 Tekin Suleyman. See LICENSE for details.
FAQs
Unknown package
We found that facebook_api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.