Skip to content

Instantly share code, notes, and snippets.

View SecureCloud-biz's full-sized avatar

Terry DeSimone SecureCloud-biz

View GitHub Profile
@SecureCloud-biz
SecureCloud-biz / fb_login_4.0.php
Created July 12, 2014 23:37
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>';
@SecureCloud-biz
SecureCloud-biz / fb_sdk_4_Login_and_GetUserName.php
Created July 12, 2014 23:39
FACEBOOK SDK 4.0.0 FOR PHP: A WORKING SAMPLE TO GET STARTED
<?php
session_start();
require_once( 'Facebook/FacebookSession.php' );
require_once( 'Facebook/FacebookRedirectLoginHelper.php' );
require_once( 'Facebook/FacebookRequest.php' );
require_once( 'Facebook/FacebookResponse.php' );
require_once( 'Facebook/FacebookSDKException.php' );
require_once( 'Facebook/FacebookRequestException.php' );
require_once( 'Facebook/FacebookAuthorizationException.php' );
@SecureCloud-biz
SecureCloud-biz / fb_4.0.0_chain.php
Created July 12, 2014 23:40
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();
@SecureCloud-biz
SecureCloud-biz / fb_4.0.x.php
Created July 12, 2014 23:41
Facebook PHP SDK 4.0.0 Example
<?php
// include required files form Facebook SDK
// added in v4.0.5
require_once( 'Facebook/FacebookHttpable.php' );
require_once( 'Facebook/FacebookCurl.php' );
require_once( 'Facebook/FacebookCurlHttpClient.php' );
// added in v4.0.0
@SecureCloud-biz
SecureCloud-biz / action_links.html
Created July 12, 2014 23:42
Adding action links to posts using JavaScript and the FB.UI Feed dialog.
@SecureCloud-biz
SecureCloud-biz / php_action_link.php
Created July 12, 2014 23:42
Adding actions to Facebook Posts
@SecureCloud-biz
SecureCloud-biz / photo_comment.php
Created July 12, 2014 23:43
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)
@SecureCloud-biz
SecureCloud-biz / console_message.js
Created July 12, 2014 23:48
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! Why are you looking here for?\nDeveloped by SecureCloud http://www.securecloud.biz", "color: #359AD8; font-size: 18px; font-family: 'Trebuchet MS', Helvetica, sans-serif;" );
} else {
console.log( "Hey! Why are you looking here for?\nDeveloped by SecureCloud http://www.securecloud.biz" );
@SecureCloud-biz
SecureCloud-biz / cover_image_url.php
Created July 12, 2014 23:50
Script to upload a photo and set it as the cover image for a Facebook Page
<?php
// Script to upload a photo by URL (i.e. remote resource) Use Above Script
// upload a photo to facebook by URL, will return id of uploaded photo
$photo_uploaded = $facebook->api( $page_id . "/photos", "POST", array(
'url' => 'http://healthhub.co/wp-content/uploads/2014/02/Group-Slider.jpg', // remote URL to image
'no_story' => true // suppress automatic image upload story, optional
) );
@SecureCloud-biz
SecureCloud-biz / cover_photo_upload.php
Created July 12, 2014 23:51
Script to upload a photo and set it as the cover image for a Facebook Page
<?php
// include Facebook PHP SDK
include "facebook/facebook.php";
// init Facebook SDK with app settings
$facebook = new Facebook( array( 'appId' => APP_ID, 'secret' => APP_SECRET ) );
// enable file upload support
$facebook->setFileUploadSupport( true );