定制 nazmulhasan/laravel-facebook-post 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub Downloads (all assets, all releases) GitHub License GitHub forks GitHub Repo stars

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?

  1. At first create a business type facebook app. Create app from Facebook Deveoper Panel
  2. Go to Facebook Graph Api Explorer
  3. Here you will see three select option:
  • Meta App
  • User or Page
  • Permissions
  1. Meta App: Here you will see all facebook app that you have created. Select your business type app from the dropdown list.
  2. 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.
  3. Permissions: Please select the following permission from this permission list
  • pages_show_list
  • pages_read_engagement
  • pages_manage_engagement
  • pages_manage_posts
  • pages_read_user_content
  1. Finally click on the Generate Access Token button and it will generate temporary access token for one hour.

  2. 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 Debug button. Then it will show token information. Scroll down this page and you will see Extend Access Token. Click on this button and it will generate long lived access token.Then copy the access token and use this as FACEBOOK_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 from User or Page section 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-token and you will get app-scoped-user-id from 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 as FACEBOOK_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 我们能提供哪些服务?
定制开发 / 二次开发

基于 nazmulhasan/laravel-facebook-post 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 415
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 23
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-23