GithubHelp home page GithubHelp logo

deepeshkumar322 / facebook-sdk-v4-codeigniter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from darkwhispering/facebook-sdk-codeigniter

0.0 2.0 0.0 167 KB

Library for integration of Facebook PHP SDK v4 with CodeIgniter 3

Home Page: http://darkwhispering.com

License: MIT License

PHP 100.00%

facebook-sdk-v4-codeigniter's Introduction

Facebook PHP SDK v4 for CodeIgniter

Library for integration of Facebook PHP SDK v4 with CodeIgniter 3

New beta version available with support for latest Facebook PHP SDK v5. More details here

Version: 2.0.0

Requirements

Notice

Facebook Canvas support is experimental as I have not been able to test or confirm it working. If you test it, please report back if you had success or failure.

This library do not include or support all available Facebook Graph methods. Any contribution is welcome to add more. But, please read the contributing rules before submitting any pull requests.

Installation

  1. Download the library files and add the files to your CodeIgniter installation. Only the library, config and composer.json files are required.
  2. In CodeIgniter /application/config/config.php set $config['composer_autoload'] to TRUE.
  3. In CodeIgniter /application/config/config.php, configure the Session Variables.
  4. Update the facebook.php config file in /application/config/facebook.php with you Facebook App details.
  5. Install the Facebook PHP SDK by navigating to your applications folder and execute composer install.
  6. Autoload the library in autoload.php or load it in needed controllers with $this->load->library('facebook');.
  7. Enjoy!

Usage

The library download includes a sample controller and views. The example code might not be the best or most beautiful code, but it is there to help you get started quicker.

Methods

logged_in()

Check if user is logged

$this->facebook->logged_in();

login_url()

Get login url. This method will only return a URL when using the redirect (web) login method.

$this->facebook->login_url();

logout_url()

Check if user is logged. This method will only return a URL when using the redirect (web) login method.

$this->facebook->logout_url();

destroy_session()

Should only be used on the logout redirect url location. This method will unset the Facebook token cookie set by this library only. This method can not be used to log out a user!

$this->facebook->destroy_session();

user_id()

Check user id.

$this->facebook->user_id();

user()

Check user details.

$this->facebook->user();

get_post()

Get post from users wall. Requires user has approved read_stream permission

/**
* Retrieve a single post from users wall
*
* Required permission: read_stream
*
* @param   int     $id   Post ID
*
* @return  array
**/
$this->facebook->get_post($id);

publish_text()

Publish a text to users wall. Requires user has approved publish_actions permission

/**
* Publish a post to the users feed
*
* Required permission: publish_actions
*
* @param   string  $message  Message to publish
*
* @return  array
**/
$this->facebook->publish_text($message);

publish_video()

Publish a video to users wall. Requires user has approved publish_actions permission

/**
* Publish (upload) a video to the users feed
*
* Required permission: publish_actions
*
* @param   string  $file         Path to video file
* @param   string  $description  Video description text
* @param   string  $title        Video title text
*
* @return  array
**/
$this->facebook->publish_video($file, $description, $title);

publish_image()

Publish a image to users wall. This method support externally hosted images only. Requires user has approved publish_actions permission

/**
* Publish image to users feed
*
* Supports externally hosted images only! No direct upload
* to Facebook.com albums at this time.
*
* Required permission: publish_actions
*
* @param   string  $image    URL to image
* @param   string  $message  Image description text
*
* @return  array
**/
$this->facebook->publish_image($image, $message);

Return data format

Most methods will return an array that include status code and message values so that you can do appropiet actions depending on if, for example, a publishing of a image was successfull or not. A list of more error codes and messages can be found here

Example of returned result for user()

Array
(
    [code] => 200
    [message] => success
    [data] => Array
    (
        [id] => 3241823947947890785957
        [email] => [email protected]
        [first_name] => John
        [gender] => Male
        [last_name] => Doe
        [link] => https://www.facebook.com/app_scoped_user_id/3241823947947890785957/
        [locale] => en_US
        [name] => John Doe
        [timezone] => -7
        [updated_time] => 2015-04-03T03:22:50+0000
        [verified] => 1
    )
)

facebook-sdk-v4-codeigniter's People

Contributors

darkwhispering avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.