Skip to content

Instantly share code, notes, and snippets.

View ravikiranj's full-sized avatar

Ravikiran Janardhana ravikiranj

View GitHub Profile
var headID = document.getElementsByTagName("head")[0];
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = 'http://www.somedomain.com/somescript.js';
headID.appendChild(newScript);
@ravikiranj
ravikiranj / facebookapp_1.php
Created May 6, 2011 03:52
Facebook Object instantiation
<?php
//require '../src/facebook.php'; //Change this line to point to the correct file path
require 'php-sdk/src/facebook.php';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => '__your__appId__',
'secret' => '__your__appSecret__',
'cookie' => true,
));
@ravikiranj
ravikiranj / facebookapp_2.php
Created May 6, 2011 04:25
Facebook App recoread object instantiation
class fbrecoread{
<?php
/* Private variables and Constants */
const APP_ID = '212318288788000';
const APP_SECRET = '7ae17a52b5f43df287327293644ff364';
private $fb = null;
private $session = null;
public function __construct($args = array()){
// Create our Application instance (replace this with your appId and secret).
@ravikiranj
ravikiranj / facebookapp_3.php
Created May 6, 2011 04:44
Show Connect to FB
<?php
/*
* function to show connectToFB button
*/
function showConnectToFB($sessionExpired = false){
$params = array();
/* You will need to request additional permissions if you want to access user's and his/her friends interests */
/* Comment out the below 2 lines if you don't need so */
$params = array("req_perms" => "user_interests,user_likes,user_status,friends_interests,friends_likes,friends_status",
"fbconnect" => 0);
@ravikiranj
ravikiranj / facebookapp_4.php
Created May 6, 2011 04:55
Generate FB Connect URl
<?php
$params = array();
/*
* You will need to request additional permissions if you want to access user's and
* his/her friends interests. Comment out the below 2 lines if you don't need so
*/
$params = array("req_perms" => "user_interests,user_likes,user_status,friends_interests,friends_likes,friends_status",
"fbconnect" => 0);
$loginUrl = $this->fb->getLoginUrl($params);
@ravikiranj
ravikiranj / facebookapp_5.php
Created May 6, 2011 05:23
Obtaining Facebook User's data via FB Graph API and FQL
<?php
try {
// Get UID of the user
$uid = $this->fb->getUser();
// Get basic info about the user
$me = $this->fb->api('/me');
// Get the user's facebook stream
@ravikiranj
ravikiranj / facebook_6
Created May 6, 2011 15:02
Hosts file
#the below rules will make ravikiranj.net point to your local web server
127.0.0.1 ravikiranj.net
127.0.0.1 www.ravikiranj.net
@ravikiranj
ravikiranj / facebook_7.php
Created May 6, 2011 16:19
Extract news items from Google news API via YQL
<?php
public function displayHTML(){
try {
$uid = $this->fb->getUser();
$me = $this->fb->api('/me');
$musicInterests = $this->fb->api('/me/music');
$musicArr = null;
if(!empty($musicInterests['data'])){
foreach($musicInterests['data'] as $item){
$musicArr[] = $item["name"];
@ravikiranj
ravikiranj / infinte_scroll_1.php
Last active September 26, 2015 07:07
infinite_scroll_curl_twitter_timeline
<?php
/**
* Function to get RSS Feed Items
*
* @param String $user, Integer $page
* @return object response
*/
function getRSSFeedItems($limit, $offset) {
$baseURL = "http://query.yahooapis.com/v1/public/yql?";
$query = "select title,link,pubDate from rss where url='http://rss.news.yahoo.com/rss/topstories' limit ${limit} offset {$offset}";
@ravikiranj
ravikiranj / infinte_scroll_2.php
Last active September 26, 2015 07:07
infinite_scroll_markup_generation
<?
/**
* Function to build RSS item markup
*
* @param Array $data, Boolean $xhr
* @return String $html
*/
function displayHTML($data, $xhr) {
if(!$xhr){
$html = <<<HTML