A laravel 5 package for reading and writing to facebook graph object with ease in laravelish syntax

Overview

Fluent-Facebook

License StyleCI Twitter URL

Docs

A laravel 5 package for reading and writing to facebook graph object with ease in laravelish syntax. Check out how easy it is to read from facebook graph api.

$user = Auth::user();
$user = Fluent::user($user->fb_id)->get();

That's it. The $user object is a collection (Illuminate\Support\Collection) of facebook user data.

If you want extra information like about, first_name, education etc. just pass an array with the field name in with method.

$user = Auth::user();
$fields = ['hometown', 'first_name', 'about', 'birthday', 'cover', 'education'];
$user = Fluent::user($user->fb_id)->with($fields)->get();

If you want to get the feed of the user just chain the feed method to the user object.

$user = Auth::user();
$feed = Fluent::user($user->fb_id)->feed()->get();

If you want to get information of a post just pass the post id to the post method.

$user = Auth::user();
$posts = Fluent::post($post_id)->get();

Install

You can pull in the package via composer:

$ composer require iluminar/fluent-facebook

Or you can add this in your composer.json

"require": {
    "iluminar/fluent-facebook": "dev-develop"
}

and then terminal from your root directory of project run following command

$ composer update

After updating composer, add a fluent service provider to the providers array in config/app.php file.

 'providers' => array(
        // ...
        Iluminar\Fluent\Providers\FluentServiceProvider::class,
    )

then run in terminal

$ php artisan vendor:publish

to add package tables in your database run following command

$ php artisan migrate

Configuration

First you have to create a facebook app and set the app_id, app_secret and redirect_uri in the configuration file.

'facebook' => [
    'client_id' => env('FB_APP_ID'),
    'client_secret' => env('FB_APP_SECRET'),
    'redirect_uri' => env('FB_REDIRECT_URI'),
],

To define what permissions your app need you can set those permission under scopes key. Just change the value of particular permission scope to true. By default email permission is set to true. Remember, for extra permission you have to submit your app for review by facebook.

false, "user_friends" => false, "email" => true, "user_about_me" => false, ] ">
'scope' => [
    "public_profile" => false,
    "user_friends" => false,
    "email" => true,
    "user_about_me" => false,
]

For user authentication fluent use laravel's default users table and user model. But if you use different table and model then set those on config file.

'user_model' => 'user',
'user_table_name' => 'users',
'user_model_namespace' => 'App',

Usage

Logging The User Into Laravel

All the routes and authentication logic for authentication via facebook is provided by package. Just add redirect route to your login button, it will redirect the user to facebook login dialog box.

Get different node information

Facebook information is represented as a social graph which composed of following three things

nodes - basically "things" such as a User, a Photo, a Page, a Comment

edges - the connections between those "things", such as a Page's Photos, or a Photo's Comments

fields - info about those "things", such as a person's birthday, or the name of a Page

First you need to instantiate a Fluent instance.

$fluent = new Fluent();

Or if you use fluent facade then you dont need a fluent instance.

Now if you want information about a user or photo, just call a method by that name on fluent object, pass the id of that node i.e id of the user or photo and chained that with get method which will return a collection about that node.

$user = Fluent::user($id)->get();

N.B: The facebook id of the user is saved in fb_id column of the users table.

When you retrieving a node information you can also specify the fields for that node to get extra information. For that just pass an array of fields name to the with method chained to that node call.

$fields = ['link', 'name', 'album'];
$photo = Fluent::photo($id)->with($fields)->get();

To get information of an node's edge (e.g photo's comments) just chain a method by the edge name to the node call.

$photo = Fluent::photo($id)->comments()->get();

Documentation

Docs

TODO

publish option

Error handling

Security Vulnerabilities

If you discover a security vulnerability in the package, please send an e-mail to Nehal Hasnayeen at [email protected]. All security vulnerabilities will be promptly addressed.

License

The Fluent-facebook is open-sourced software licensed under the MIT license.

Change log

Please see CHANGELOG for more information what has changed recently.

Contributor

Made by Hasnayeen with love in Bangladesh

You might also like...
A Laravel package to help integrate Shopware PHP SDK much more easier

Shopware 6 Laravel SDK A Laravel package to help integrate Shopware PHP SDK much more easier Installation Install with Composer composer require sas/s

laravel package untuk memudahkan penggunaan MCA dengan Telegram Bot USDI di aplikasi Universitas Udayana.

MCA KubeMQ Laravel laravel package untuk memudahkan penggunaan MCA dengan Telegram Bot USDI di aplikasi Universitas Udayana. Motivasi Proyek ini berfu

Google VerifiedSMS Laravel Package

Google VerifiedSMS Laravel Package This is a laravel package developed for google business communication api and verified SMS API. Before we commence

A Laravel wrapper for thephpleague's Fractal package

laravel-api-response A Laravel wrapper for thephpleague's Fractal package Install Via Composer composer require lykegenes/laravel-api-response Then, a

Telegraph - a Laravel package for fluently interaction with Telegram Bots
Telegraph - a Laravel package for fluently interaction with Telegram Bots

Telegraph - a Laravel package for fluently interaction with Telegram Bots

Laravel 8.x package wrapper library for Metatrader 5 Web API

Laravel 8.x package wrapper library for Metatrader 5 Web API

⚡ Setting up Apache and PHP on AWS with Ansible Playbook Using Ubuntu 22.04 AMI.   Ansible is a simple and powerful automation engine. It is used to help with configuration management, application deployment, and task automation. It makes your applications and systems easier to deploy and maintain .
PHP package to manage google-api interactions

Google-api-client PHP package to manage google-api interactions Supports: Google Drive API Google Spreadsheet API Installation composer require obrio-

PHP package for the Limg.app website - allowing to upload images via the API of the website.
PHP package for the Limg.app website - allowing to upload images via the API of the website.

Limg PHP Client Package. Installation You can install the package via composer: composer require havenstd06/limg-php-client Usage use Havenstd06\Limg\

Comments
  • The parameter app_id is required

    The parameter app_id is required

    I just pooled in the fluent-facebook, set my FB_APP_ID and SECRET i my .env, did everything else according to the doc but when I hit my login button I get this facebook error: The parameter app_id is required in the broser Help please

    opened by tnaffh 6
Owner
iluminar
Building solution for ̶r̶o̶b̶o̶t̶ human
iluminar
Facebook GraphQL for Laravel 5. It supports Relay, eloquent models, validation and GraphiQL.

Laravel GraphQL This package is no longuer maintained. Please use rebing/graphql-laravel or other Laravel GraphQL packages Use Facebook GraphQL with L

Folklore Inc. 1.8k Dec 11, 2022
A simple PHP GitHub API client, Object Oriented, tested and documented.

PHP GitHub API A simple Object Oriented wrapper for GitHub API, written with PHP. Uses GitHub API v3 & supports GitHub API v4. The object API (v3) is

KNP Labs 2k Jan 7, 2023
A simple Object Oriented PHP Client for Termii SMS API

Termii Client A simple Object Oriented PHP Client for Termii SMS API. Uses Termii API. Requirements PHP >= 7.2 Guzzlehttp ~6|~7 Installation Via Compo

Ilesanmi Olawale Adedotun 5 Feb 24, 2022
NovaGram - An elegant, Object-Oriented, reliable PHP Telegram Bot Library

An elegant, Object-Oriented, reliable PHP Telegram Bot Library Full Documentation • Public support group Examples • Features • Installation ?

Gaetano 165 Jan 6, 2023
Laravel Package for 1APP. Learn how to integrate our APIs to build a web or mobile integration to send and accept payments for your application and businesses.

1APP Laravel Library Learn how to integrate our APIs to build a web or mobile integration to accept payments, make payment of Bills and as well custom

O'Bounce Technologies 4 Jul 25, 2022
A Laravel package to retrieve pageviews and other data from Google Analytics

Retrieve data from Google Analytics Using this package you can easily retrieve data from Google Analytics. Here are a few examples of the provided met

Spatie 2.8k Jan 7, 2023
A simple API documentation package for Laravel using OpenAPI and Redoc

Laravel Redoc Easily publish your API documentation using your OpenAPI document in your Laravel Application. Installation You can install this package

Steve McDougall 15 Dec 27, 2022
This package is a simple API laravel wrapper for Pokemontcg with a sleek Model design for API routes and authentication.

This package is a simple API laravel wrapper for Pokemontcg with a sleek Model design for API routes and authentication.

Daniel Henze 3 Aug 29, 2022
PHP package providing easy and fast access to Twitter API V2.

Twitter API V2 is a PHP package that provides an easy and fast access to Twitter REST API for Version 2 endpoints.

Julien SCHMITT 38 Dec 12, 2022
HTTP Requestor: Package for a client request that supports you to make an external service request easily and with fast usage.

HttpRequestor from Patienceman HTTP Requestor: Package for a client request that supports you to make an external service request easily and with fast

Manirabona Patience 2 Aug 26, 2022