This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 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 | |
) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// post to facebook - requires publish_actions permission | |
$post = $facebook->api( "me/feed", "POST", array( | |
'message' => 'Testing custom search action', | |
'actions' => array( | |
'name' => 'Search', | |
'link' => 'http://www.google.com' | |
) | |
) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="well"> | |
<button class="btn btn-info share-btn">Share</button> | |
</div> | |
<script type="text/javascript"> | |
function fb_share() { | |
FB.ui( { | |
method: 'feed', | |
name: "Search Google", | |
link: "https://www.google.com", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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>'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// make api call | |
$response = (new FacebookRequest( | |
$session, 'POST', '/me/feed', array( | |
'message' => 'testing' | |
) | |
))->execute()->getGraphObject()->asArray(); | |
// output response - should include post_id |