Skip to content

Instantly share code, notes, and snippets.

View niraj-shah's full-sized avatar
🏠
Working from home

Niraj Shah niraj-shah

🏠
Working from home
View GitHub Profile
@niraj-shah
niraj-shah / ban_user.php
Last active December 21, 2015 00:48
Ban a user from your Facebook Application using PHP
<?php
// change these to match your app
$app_id = '1234567890';
$app_secret = 'abcdefghijklmnopqrstuvwxyz';
// init facebook class
$facebook = new Facebook( array( 'appId' => $app_id, 'secret' => $app_secret ) );
/* Ban Users */
Array
(
[algorithm] => HMAC-SHA256
[issued_at] => 1378146888
[page] => Array
(
[id] => 1234567890
[liked] => 1
[admin] => 1
)
<?php
$sr = $facebook->getSignedRequest();
// check if the page has been liked
if ( !isset( $sr ) || !isset( $sr['page']['liked'] ) || $sr['page']['liked'] != true ) {
// likegate
header( 'Location: likegate.php' );
} else {
// regular content
@niraj-shah
niraj-shah / fb_long_access_token.php
Created September 17, 2013 20:41
Getting a long-lived access token using the Facebook PHP SDK
<?php
$appId = 'aaaaaaaaaaaa';
$appSecret = 'bbbbbbbbbbbb';
// init facebook
$facebook = new Facebook( array( 'appId' => $appId, 'secret' => $appSecret ) );
// get user_id, 0 if not logged in
$user = $facebook->getUser();
@niraj-shah
niraj-shah / google+_share.html
Last active December 24, 2015 12:29
Adding an interactive share button to your web page
<div class="well">
<button
class="g-interactivepost btn btn-info"
data-contenturl="https://play.google.com/store/apps/details?id=com.cagecricket.app"
data-contentdeeplinkid=""
data-clientid="xxxxx.apps.googleusercontent.com"
data-cookiepolicy="single_host_origin"
data-prefilltext="Download the Cage Cricket application and easily record your scores for this great urban-friendly version of Cricket."
data-calltoactionlabel="INSTALL_APP"
data-calltoactionurl="https://play.google.com/store/apps/details?id=com.cagecricket.app"
@niraj-shah
niraj-shah / scrollbars.js
Last active December 25, 2015 00:19
Removing Facebook Page App Scrollbars
window.fbAsyncInit = function() {
FB.init({
appId : 'xxx', // App ID
channelUrl : 'channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Remove those pesky scrollbars
@niraj-shah
niraj-shah / fb_max_width.css
Created October 8, 2013 16:18
CSS for restricting Facebook Page App width
html, body {
width: 810px;
overflow: hidden;
}
@niraj-shah
niraj-shah / fb_scrolling.html
Created October 8, 2013 16:51
Facebook Page App Scrolling Examples
<!-- anchor example -->
<a href="#" onclick="FB.Canvas.scrollTo( 0, 500 );">Click here to enter</a>
<!-- anchor with jQuery dynamic placement example -->
<a href="#" onclick="FB.Canvas.scrollTo( 0, $('.enter-btn').offset().top );">Click here to enter</a>
<!-- page load example -->
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
@niraj-shah
niraj-shah / fb_frame_info.js
Created October 8, 2013 17:29
Get frame information for Facebook Page App
FB.Canvas.getPageInfo( function(info) {
console.log(info);
});
@niraj-shah
niraj-shah / add_to_page.html
Last active December 25, 2015 00:29
Adding applications to pages
<script type="text/javascript">
function addToPage() {
var obj = {
method: 'pagetab',
redirect_uri: '[redirect_url]',
};
FB.ui(obj);
}
</script>