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 / tag_store.php
Created July 12, 2014 22:54
Using a ID from taggable_friends to post Status Update using Graph API 2.0 and Facebook PHP SDK 4.0.x
<?php
// requires Facebook PHP SDK 4.0.x or later
// user must be logged-in prior to API call
// publish story, requires 'places' attribute
// use a page_id with no address to tag hidden location
// $tags is a comma-separated string of IDs
$story = (new FacebookRequest( $session, 'POST', '/me/feed', array(
@SecureCloud-biz
SecureCloud-biz / fb_4.0.x.php
Created July 12, 2014 22:58
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 / PHP_Server_Generated_SESSION.php
Created July 12, 2014 23:02
PHP_Server_Generated_SESSION
<?php
// [Accept only server-generated SIDs]
// One way to improve security is not to accept session identifiers that were not generated by the
// server. However, as noted above, this does not prevent all session fixation attacks.
if (!isset($_SESSION['SERVER_GENERATED_SID'])) {
session_destroy(); // destroy all data in session
}
session_regenerate_id(); // generate a new session identifier
$_SESSION['SERVER_GENERATED_SID'] = true;
<?php
session_start();
if (isset($_SESSION['screen_width']) AND isset($_SESSION['screen_height'])) {
echo 'User resolution: ' . $_SESSION['screen_width'] . 'x' . $_SESSION['screen_height'];
} else if(isset($_REQUEST['width']) AND isset($_REQUEST['height'])) {
$_SESSION['screen_width'] = $_REQUEST['width'];
$_SESSION['screen_height'] = $_REQUEST['height'];
header('Location: ' . $_SERVER['PHP_SELF']);
} else {
@SecureCloud-biz
SecureCloud-biz / index.php
Created July 12, 2014 23:31
PHP file to redirect visitors to iOS or Android app files
<?php
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
$iPod = stripos( $_SERVER['HTTP_USER_AGENT'], "iPod" );
$iPhone = stripos( $_SERVER['HTTP_USER_AGENT'], "iPhone" );
$iPad = stripos( $_SERVER['HTTP_USER_AGENT'], "iPad" );
$Android = stripos( $_SERVER['HTTP_USER_AGENT'], "Android" );
$webOS = stripos( $_SERVER['HTTP_USER_AGENT'], "webOS" );
@SecureCloud-biz
SecureCloud-biz / fb_tab_app_4.0.x.php
Created July 12, 2014 23:33
Creating a Facebook Page Tab App using the Facebook PHP SDK 4.0.x
<?php
// required Facebook PHP SDK v4.0.9 or later.
// 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' );
@SecureCloud-biz
SecureCloud-biz / ci_fb_sdk_4.0.txt
Created July 12, 2014 23:34
Facebook PHP SDK 4.0.x with CodeIgnitor
.
└── /
├── application
│ ├── cache
│ ├── config
│ ├── controllers
│ ├── core
│ ├── errors
│ ├── helpers
│ ├── hooks
@SecureCloud-biz
SecureCloud-biz / fb_sdk_4.0_structure.txt
Created July 12, 2014 23:35
Facebook PHP SDK 4.0.x File Structure
.
└── app
├── Facebook
│ ├── FacebookCanvasLoginHelper.php
│ ├── FacebookCurl.php
│ ├── FacebookHttpable.php
│ ├── FacebookCurlHttpClient.php
│ ├── FacebookJavaScriptLoginHelper.php
│ ├── FacebookPageTabHelper.php
│ ├── FacebookRedirectLoginHelper.php
@SecureCloud-biz
SecureCloud-biz / fb-post-extended-4.0.x.php
Created July 12, 2014 23:35
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'
)
@SecureCloud-biz
SecureCloud-biz / fb-post-4.0.x.php
Created July 12, 2014 23:36
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