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 / fb_sdk_4.0_structure.txt
Created June 7, 2014 11:19
Facebook PHP SDK 4.0.x File Structure
.
└── app
├── Facebook
│ ├── FacebookCanvasLoginHelper.php
│ ├── FacebookCurl.php
│ ├── FacebookHttpable.php
│ ├── FacebookCurlHttpClient.php
│ ├── FacebookJavaScriptLoginHelper.php
│ ├── FacebookPageTabHelper.php
│ ├── FacebookRedirectLoginHelper.php
@niraj-shah
niraj-shah / fb-post-extended-4.0.x.php
Created May 29, 2014 10:10
Posting to Timeline using PHP SDK 4.0.x with additional parameters
<?php
// make api call
$response = (new FacebookRequest(
$session, 'POST', '/me/feed', array(
'name' => 'Facebook API: Posting a Status Update Using PHP SDK 4.0.x',
'caption' => "I'm rewriting old tutorials to work with the new PHP SDK 4.0 and Graph API 2.0.",
'link' => 'https://www.webniraj.com/2014/05/29/facebook-api-p…-php-sdk-4-0-x/',
'message' => 'Check out my new tutorial'
)
@niraj-shah
niraj-shah / fb-post-4.0.x.php
Created May 29, 2014 10:05
Posting to Timeline using PHP SDK 4.0.x
<?php
// make api call
$response = (new FacebookRequest(
$session, 'POST', '/me/feed', array(
'message' => 'testing'
)
))->execute()->getGraphObject()->asArray();
// output response - should include post_id
@niraj-shah
niraj-shah / fb_login_4.0.php
Created May 6, 2014 08:50
Facebook Login using PHP SDK 4.0.0 with additional permissions
<?php
// include code from https://gist.github.com/niraj-shah/ab1c74ad83df172e6075
// generate login url with scope, each permission as element in array
$loginUrl = $helper->getLoginUrl( array( 'email', 'user_friends' ) );
// output login link
echo '<a href="' . $loginUrl . '">Login</a>';
@niraj-shah
niraj-shah / fb_4.0.0_chain.php
Last active August 29, 2015 14:00
Example of chaining using Facebook PHP SDK 4.0.0
<?php
// turn this:
$request = new FacebookRequest( $session, 'GET', '/me' );
$response = $request->execute();
$graphObject = $response->getGraphObject();
// into this:
$graphObject = (new FacebookRequest( $session, 'GET', '/me' ))->execute()->getGraphObject()->asArray();
@niraj-shah
niraj-shah / fb_4.0.x.php
Last active September 7, 2019 15:56
Facebook PHP SDK 4.0.0 Example
<?php
// include required files form Facebook SDK
require_once( 'Facebook/HttpClients/FacebookHttpable.php' );
require_once( 'Facebook/HttpClients/FacebookCurl.php' );
require_once( 'Facebook/HttpClients/FacebookCurlHttpClient.php' );
require_once( 'Facebook/Entities/AccessToken.php' );
require_once( 'Facebook/Entities/SignedRequest.php' );
@niraj-shah
niraj-shah / action_links.html
Created March 26, 2014 12:21
Adding action links to posts using JavaScript and the FB.UI Feed dialog.
@niraj-shah
niraj-shah / php_action_link.php
Created March 26, 2014 12:05
Adding actions to Facebook Posts
@niraj-shah
niraj-shah / photo_comment.php
Last active June 3, 2017 06:17
Adding a comment with a photo to Facebook
<?php
include "facebook/facebook.php";
$facebook = new Facebook( array( 'appId' => APP_ID, 'secret' => APP_SECRET ) );
// enable upload support
$facebook->setFileUploadSupport( true );
// set access token for user / page here (not needed if you intend to use the login flow beforehand)
@niraj-shah
niraj-shah / console_message.js
Last active August 29, 2015 13:57
Leave a message for those pesky developers who like inspecting websites
var Util = {
is_webkit: function() {
return navigator.userAgent.indexOf("AppleWebKit") > -1;
},
message: function() {
if ( typeof console == "object" ) {
if ( Util.is_webkit() ) {
console.log( "%cHey! What are you looking under here for?\nDeveloped by Niraj Shah http://www.webniraj.com", "color: #359AD8; font-size: 18px; font-family: 'Trebuchet MS', Helvetica, sans-serif;" );
} else {
console.log( "Hey! What are you looking under here for?\nDeveloped by Niraj Shah http://www.webniraj.com" );