nazmulhasan/laravel-facebook-post
Composer 安装命令:
composer require nazmulhasan/laravel-facebook-post
包简介
This package allow to create, update, delete and get posts from facebook page in laravel application
关键字:
README 文档
README
This package allow to create, update, delete and get posts from facebook page in laravel application
Requirements
- PHP >=7.2
- Laravel >= 6
Installation
You can install the package via composer:
composer require nazmulhasan/laravel-facebook-post
Configuration
You can publish the configuration file config/facebook.php optionally by using the following command:
php artisan vendor:publish --provider="NazmulHasan\LaravelFacebookPost\FacebookPostServiceProvider" --tag="config"
Configure .env file
FACEBOOK_PAGE_ID=
FACEBOOK_ACCESS_TOKEN=
Usage
Get All posts
use NazmulHasan\LaravelFacebookPost\Facades\FacebookPost;
$response = FacebookPost::getPost();
Create Text post
use NazmulHasan\LaravelFacebookPost\Facades\FacebookPost;
$message = 'Message from laravel application';
$response = FacebookPost::storePost($message);
Create Text post with photo
use NazmulHasan\LaravelFacebookPost\Facades\FacebookPost;
$message = 'Message from laravel application'; //message is optional
$url = 'Your image url';
$response = FacebookPost::storePostWithPhoto($url, $message);
Update post
use NazmulHasan\LaravelFacebookPost\Facades\FacebookPost;
$message = 'Message from laravel application';
$post_id = 'Your post id';
$response = FacebookPost::updatePost($post_id, $message);
Delete post
use NazmulHasan\LaravelFacebookPost\Facades\FacebookPost;
$post_id = 'Your post id';
$response = FacebookPost::deletePost($post_id);
Example Success Response
array:4 [
"status" => "success"
"status_code" => 200
"message" => "Post created successfully"
"post_id" => "103408372435470_395802394384938"
]
Example Failure Response
array:3 [
"status" => "fail"
"status_code" => 422
"message" => "Message is required"
]
Limitations
- You can update only the text of a post. Image is not updatable.
- Multiple image upload is not supported.
- Video upload is not supported
How to generate access token?
- At first create a business type facebook app. Create app from Facebook Deveoper Panel
- Go to Facebook Graph Api Explorer
- Here you will see three select option:
- Meta App
- User or Page
- Permissions
Meta App: Here you will see all facebook app that you have created. Select your business type app from the dropdown list.User or Page: Here you need to select page access token. Then it will redirect you to your facebook page list. Select your preferred page and give necessary permission.Permissions: Please select the following permission from this permission list
pages_show_listpages_read_engagementpages_manage_engagementpages_manage_postspages_read_user_content
-
Finally click on the Generate Access Token button and it will generate temporary access token for one hour.
-
If you want to make this token as long lived, you need to go Access Token Debugger. Insert the access token and click on the
Debugbutton. Then it will show token information. Scroll down this page and you will seeExtend Access Token. Click on this button and it will generate long lived access token.Then copy the access token and use this asFACEBOOK_ACCESS_TOKEN
Note:
If you want to generate never expiry access token, you need to follow this step:
- Please open an api testing tool like Postman and send a get request by using this url
https://graph.facebook.com/v19.0/{app-scoped-user-id}/accounts?access_token={long-lived-user-access-token}. If you want to generate user access token instead of page access token, just select user access token fromUser or Pagesection that i have mentioned in step 5. - Extend expiry date of this user access token as like as page access token extend method that i have mentioned in step 8.
- Then debug this
long-lived-user-access-tokenand you will getapp-scoped-user-idfrom this debug information. - Finally send get request to this url
https://graph.facebook.com/v19.0/{app-scoped-user-id}/accounts?access_token={long-lived-user-access-token}. Now You will get never expiry page access token from this request and use this access token asFACEBOOK_ACCESS_TOKEN
If you face any issue or bug, please create an issue by using this link https://github.com/Nazmul7989/laravel-facebook-post/issues.
License
The MIT License (MIT). Please see License File for more information.
See Facebook Page Api for more details
See Facebook Long Lived Access Token for more details
nazmulhasan/laravel-facebook-post 适用场景与选型建议
nazmulhasan/laravel-facebook-post 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 415 次下载、GitHub Stars 达 11, 最近一次更新时间为 2024 年 03 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「graph-api」 「facebook-graph-api」 「facebook-page-api」 「laravel-facebook-post」 「laravel-facebook-page-post」 「laravel-facebook-page-api」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nazmulhasan/laravel-facebook-post 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nazmulhasan/laravel-facebook-post 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nazmulhasan/laravel-facebook-post 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
It's Instagram Graph SDK for PHP. With this package you can easily make all requests to Instagram Graph API, like Auth and CRUD. Also, we will have more methods regularly.
A Laravel package for connecting to the Meta (Facebook) Graph API.
Laravel package for Meta Marketing API — multi-account catalog management, product feeds, batch inventory, offers, diagnostics and localized catalogs.
Login and register frontend and backend users using Azure Entra
Mail driver for Laravel to send emails using the Microsoft Graph API without user authentication and SMTP
将 PHPMailer 封装成 Yii2 邮件发送组件,支持使用 Yii::$app->mail->send() 方式发送邮件
统计信息
- 总下载量: 415
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-23