Endpoints manajemen Facebook OAuth & Business Manager. Berisi: connect/disconnect FB account, list/fetch/import BM, dan list/import/rename Ad Accounts. Mayoritas memakai middleware auth:api, myapi.
Facebook OAuth
GET /api/facebook/oauth-url — URL login Facebook OAuth
Middleware: auth:api, myapi
GEThttp://127.0.0.1:8081/api/facebook/oauth-url
curl --request GET \
--url http://127.0.0.1:8081/api/facebook/oauth-url
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/facebook/oauth-url' -Method GET
const url = 'http://127.0.0.1:8081/api/facebook/oauth-url';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/facebook/oauth-url';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/facebook/oauth-url"
response = requests.get(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/facebook/oauth-url"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/facebook/oauth-url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Generate URL login Facebook OAuth untuk menghubungkan akun Facebook admin.
Response
json{
"status": true,
"data": {
"url": "https://www.facebook.com/v20.0/dialog/oauth?client_id=..."
}
}
GET /api/facebook/callback — Callback redirect OAuth
Middleware: Publik (di luar grup auth:api,myapi)
GEThttp://127.0.0.1:8081/api/facebook/callback
curl --request GET \
--url http://127.0.0.1:8081/api/facebook/callback
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/facebook/callback' -Method GET
const url = 'http://127.0.0.1:8081/api/facebook/callback';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/facebook/callback';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/facebook/callback"
response = requests.get(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/facebook/callback"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/facebook/callback",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Callback redirect setelah user approve OAuth Facebook. Menerima code dari Facebook, menukar dengan token, menyimpan ke UserFacebookToken.
GET /api/facebook/accounts — Daftar akun Facebook terhubung
Middleware: auth:api, myapi
GEThttp://127.0.0.1:8081/api/facebook/accounts
curl --request GET \
--url http://127.0.0.1:8081/api/facebook/accounts
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/facebook/accounts' -Method GET
const url = 'http://127.0.0.1:8081/api/facebook/accounts';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/facebook/accounts';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/facebook/accounts"
response = requests.get(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/facebook/accounts"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/facebook/accounts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
List akun Facebook yang sudah terhubung (dari UserFacebookToken).
Response
json{
"status": true,
"data": [
{ "id": "UUID", "facebook_user_id": "...", "facebook_user_name": "Nama", "is_active": true }
]
}
DELETE /api/facebook/accounts/{tokenId} — Disconnect akun
Middleware: auth:api, myapi
DELETEhttp://127.0.0.1:8081/api/facebook/accounts/:tokenId
curl --request DELETE \
--url http://127.0.0.1:8081/api/facebook/accounts/:tokenId
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/facebook/accounts/:tokenId' -Method DELETE
const url = 'http://127.0.0.1:8081/api/facebook/accounts/:tokenId';
const options = {method: 'DELETE'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/facebook/accounts/:tokenId';
const options = {method: 'DELETE'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/facebook/accounts/:tokenId"
response = requests.delete(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/facebook/accounts/:tokenId"
req, _ := http.NewRequest("DELETE", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/facebook/accounts/:tokenId",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Putus koneksi akun Facebook berdasarkan token ID.
| Param | Wajib | Tipe |
|---|
tokenId | ✅ | UUID/UUID |
Business Manager
Middleware: auth:api, myapi
GEThttp://127.0.0.1:8081/api/facebook/tokens/:tokenId/businesses
curl --request GET \
--url http://127.0.0.1:8081/api/facebook/tokens/:tokenId/businesses
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/facebook/tokens/:tokenId/businesses' -Method GET
const url = 'http://127.0.0.1:8081/api/facebook/tokens/:tokenId/businesses';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/facebook/tokens/:tokenId/businesses';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/facebook/tokens/:tokenId/businesses"
response = requests.get(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/facebook/tokens/:tokenId/businesses"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/facebook/tokens/:tokenId/businesses",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Ambil daftar Business Manager langsung dari Meta Graph (tidak dari DB lokal).
| Param | Wajib | Tipe |
|---|
tokenId | ✅ | UUID/UUID |
GET /api/facebook/businesses — Daftar BM tersimpan
Middleware: auth:api, myapi
GEThttp://127.0.0.1:8081/api/facebook/businesses
curl --request GET \
--url http://127.0.0.1:8081/api/facebook/businesses
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/facebook/businesses' -Method GET
const url = 'http://127.0.0.1:8081/api/facebook/businesses';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/facebook/businesses';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/facebook/businesses"
response = requests.get(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/facebook/businesses"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/facebook/businesses",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
List Business Manager yang sudah di-import ke database lokal.
POST /api/facebook/businesses/import — Import BM terpilih
Middleware: auth:api, myapi
POSThttp://127.0.0.1:8081/api/facebook/businesses/import
curl --request POST \
--url http://127.0.0.1:8081/api/facebook/businesses/import
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/facebook/businesses/import' -Method POST
const url = 'http://127.0.0.1:8081/api/facebook/businesses/import';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/facebook/businesses/import';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/facebook/businesses/import"
response = requests.post(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/facebook/businesses/import"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/facebook/businesses/import",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Import Business Manager terpilih ke database (tabel facebook_businesses).
Request body
| Field | Wajib | Tipe | Keterangan |
|---|
businessIds | ✅ | array | List BM ID dari fetch |
tokenId | ✅ | UUID/UUID | Token yang dipakai |
DELETE /api/facebook/businesses/{id} — Hapus BM lokal
Middleware: auth:api, myapi
DELETEhttp://127.0.0.1:8081/api/facebook/businesses/:id
curl --request DELETE \
--url http://127.0.0.1:8081/api/facebook/businesses/:id
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/facebook/businesses/:id' -Method DELETE
const url = 'http://127.0.0.1:8081/api/facebook/businesses/:id';
const options = {method: 'DELETE'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/facebook/businesses/:id';
const options = {method: 'DELETE'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/facebook/businesses/:id"
response = requests.delete(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/facebook/businesses/:id"
req, _ := http.NewRequest("DELETE", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/facebook/businesses/:id",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Hapus data Business Manager dari database lokal.
POST /api/business — Data single BM
Middleware: auth:api, myapi
POSThttp://127.0.0.1:8081/api/business
curl --request POST \
--url http://127.0.0.1:8081/api/business
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/business' -Method POST
const url = 'http://127.0.0.1:8081/api/business';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/business';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/business"
response = requests.post(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/business"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/business",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Ambil single data Business Manager.
POST /api/business/accounts — Akun iklan dalam BM
Middleware: auth:api, myapi
POSThttp://127.0.0.1:8081/api/business/accounts
curl --request POST \
--url http://127.0.0.1:8081/api/business/accounts
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/business/accounts' -Method POST
const url = 'http://127.0.0.1:8081/api/business/accounts';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/business/accounts';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/business/accounts"
response = requests.post(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/business/accounts"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/business/accounts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Ambil akun iklan dalam sebuah Business Manager.
POST /api/business/partner — Agensi partner
Middleware: auth:api, myapi
POSThttp://127.0.0.1:8081/api/business/partner
curl --request POST \
--url http://127.0.0.1:8081/api/business/partner
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/business/partner' -Method POST
const url = 'http://127.0.0.1:8081/api/business/partner';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/business/partner';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/business/partner"
response = requests.post(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/business/partner"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/business/partner",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Ambil daftar agensi partner (agency) dari Meta.
POST /api/business/rename — Rename BM
Middleware: auth:api, myapi
POSThttp://127.0.0.1:8081/api/business/rename
curl --request POST \
--url http://127.0.0.1:8081/api/business/rename
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/business/rename' -Method POST
const url = 'http://127.0.0.1:8081/api/business/rename';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/business/rename';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/business/rename"
response = requests.post(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/business/rename"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/business/rename",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Ubah nama Business Manager di Facebook.
Request body
| Field | Wajib | Tipe |
|---|
business_id | ✅ | string |
new_name | ✅ | string |
POST /api/business/check — Validasi business
Middleware: auth:api, myapi
POSThttp://127.0.0.1:8081/api/business/check
curl --request POST \
--url http://127.0.0.1:8081/api/business/check
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/business/check' -Method POST
const url = 'http://127.0.0.1:8081/api/business/check';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/business/check';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/business/check"
response = requests.post(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/business/check"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/business/check",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Validasi Business Manager.
POST /api/business/ads_account_add — Import akun ke BM lokal
Middleware: auth:api, myapi
POSThttp://127.0.0.1:8081/api/business/ads_account_add
curl --request POST \
--url http://127.0.0.1:8081/api/business/ads_account_add
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/business/ads_account_add' -Method POST
const url = 'http://127.0.0.1:8081/api/business/ads_account_add';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/business/ads_account_add';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/business/ads_account_add"
response = requests.post(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/business/ads_account_add"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/business/ads_account_add",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Import akun iklan ke business manager lokal (BusinessController::importBusinessAccount).
Ad Accounts
GET /api/facebook/businesses/{bmId}/ad-accounts — List akun dalam BM
Middleware: auth:api, myapi
GEThttp://127.0.0.1:8081/api/facebook/businesses/:businessId/ad-accounts
curl --request GET \
--url http://127.0.0.1:8081/api/facebook/businesses/:businessId/ad-accounts
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/facebook/businesses/:businessId/ad-accounts' -Method GET
const url = 'http://127.0.0.1:8081/api/facebook/businesses/:businessId/ad-accounts';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/facebook/businesses/:businessId/ad-accounts';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/facebook/businesses/:businessId/ad-accounts"
response = requests.get(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/facebook/businesses/:businessId/ad-accounts"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/facebook/businesses/:businessId/ad-accounts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
List akun iklan dalam satu Business Manager (dari cache facebook_ad_accounts).
POST /api/facebook/businesses/{bmId}/import-accounts — Trigger import massal
Middleware: auth:api, myapi
POSThttp://127.0.0.1:8081/api/facebook/businesses/:businessId/import-accounts
curl --request POST \
--url http://127.0.0.1:8081/api/facebook/businesses/:businessId/import-accounts
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/facebook/businesses/:businessId/import-accounts' -Method POST
const url = 'http://127.0.0.1:8081/api/facebook/businesses/:businessId/import-accounts';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/facebook/businesses/:businessId/import-accounts';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/facebook/businesses/:businessId/import-accounts"
response = requests.post(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/facebook/businesses/:businessId/import-accounts"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/facebook/businesses/:businessId/import-accounts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Trigger background import seluruh akun iklan dalam BM via queue job ImportAdAccountsJob.
Response
json{
"status": true,
"data": {
"import_job_id": "UUID",
"status": "queued"
}
}
POST /api/facebook/ad-accounts/{accId}/update-name — Ubah nama akun
Middleware: auth:api, myapi
POSThttp://127.0.0.1:8081/api/facebook/ad-accounts/:accountId/update-name
curl --request POST \
--url http://127.0.0.1:8081/api/facebook/ad-accounts/:accountId/update-name
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/facebook/ad-accounts/:accountId/update-name' -Method POST
const url = 'http://127.0.0.1:8081/api/facebook/ad-accounts/:accountId/update-name';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/facebook/ad-accounts/:accountId/update-name';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/facebook/ad-accounts/:accountId/update-name"
response = requests.post(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/facebook/ad-accounts/:accountId/update-name"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/facebook/ad-accounts/:accountId/update-name",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Ubah nama akun iklan di Facebook.
Request body
| Field | Wajib | Tipe |
|---|
name | ✅ | string |
POST /api/facebook/ad-accounts/{accId}/update-name-with-partner — Rename + assign partner
Middleware: auth:api, myapi
POSThttp://127.0.0.1:8081/api/facebook/ad-accounts/:accountId/update-name-with-partner
curl --request POST \
--url http://127.0.0.1:8081/api/facebook/ad-accounts/:accountId/update-name-with-partner
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/facebook/ad-accounts/:accountId/update-name-with-partner' -Method POST
const url = 'http://127.0.0.1:8081/api/facebook/ad-accounts/:accountId/update-name-with-partner';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/facebook/ad-accounts/:accountId/update-name-with-partner';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/facebook/ad-accounts/:accountId/update-name-with-partner"
response = requests.post(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/facebook/ad-accounts/:accountId/update-name-with-partner"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/facebook/ad-accounts/:accountId/update-name-with-partner",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Rename akun + assign partner BM agensi.
POST /api/facebook/ad-accounts/check-partnership — Cek partnership
Middleware: auth:api, myapi
POSThttp://127.0.0.1:8081/api/facebook/ad-accounts/check-partnership
curl --request POST \
--url http://127.0.0.1:8081/api/facebook/ad-accounts/check-partnership
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/facebook/ad-accounts/check-partnership' -Method POST
const url = 'http://127.0.0.1:8081/api/facebook/ad-accounts/check-partnership';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/facebook/ad-accounts/check-partnership';
const options = {method: 'POST'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/facebook/ad-accounts/check-partnership"
response = requests.post(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/facebook/ad-accounts/check-partnership"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/facebook/ad-accounts/check-partnership",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Cek status partnership akun iklan.
Import Jobs
GET /api/facebook/import-jobs/{jobId} — Status import
GEThttp://127.0.0.1:8081/api/facebook/import-jobs/:jobId
curl --request GET \
--url http://127.0.0.1:8081/api/facebook/import-jobs/:jobId
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/facebook/import-jobs/:jobId' -Method GET
const url = 'http://127.0.0.1:8081/api/facebook/import-jobs/:jobId';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/facebook/import-jobs/:jobId';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/facebook/import-jobs/:jobId"
response = requests.get(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/facebook/import-jobs/:jobId"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/facebook/import-jobs/:jobId",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Cek status/progress import akun.
Response
json{
"status": true,
"data": {
"id": "UUID",
"status": "processing",
"total_items": 500,
"processed_items": 123,
"started_at": "2026-08-21T10:00:00+07:00"
}
}
GET /api/facebook/import-jobs/{jobId}/cancel — Batalkan import
GEThttp://127.0.0.1:8081/api/facebook/import-jobs/:jobId/cancel
curl --request GET \
--url http://127.0.0.1:8081/api/facebook/import-jobs/:jobId/cancel
$response = Invoke-WebRequest -Uri 'http://127.0.0.1:8081/api/facebook/import-jobs/:jobId/cancel' -Method GET
const url = 'http://127.0.0.1:8081/api/facebook/import-jobs/:jobId/cancel';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = 'http://127.0.0.1:8081/api/facebook/import-jobs/:jobId/cancel';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
import requests
url = "http://127.0.0.1:8081/api/facebook/import-jobs/:jobId/cancel"
response = requests.get(url)
print(response.json())
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://127.0.0.1:8081/api/facebook/import-jobs/:jobId/cancel"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8081",
CURLOPT_URL => "http://127.0.0.1:8081/api/facebook/import-jobs/:jobId/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Batalkan proses import yang berjalan.
Ringkasan endpoint
| Method | Endpoint | Middleware | Fungsi |
|---|
| GET | /api/facebook/oauth-url | auth:api,myapi | URL OAuth |
| GET | /api/facebook/callback | Publik | Callback OAuth |
| GET | /api/facebook/accounts | auth:api,myapi | List FB account |
| DELETE | /api/facebook/accounts/{tokenId} | auth:api,myapi | Disconnect |
| GET | /api/facebook/tokens/{tokenId}/businesses | auth:api,myapi | Fetch BM dari Meta |
| GET | /api/facebook/businesses | auth:api,myapi | List BM tersimpan |
| POST | /api/facebook/businesses/import | auth:api,myapi | Import BM |
| DELETE | /api/facebook/businesses/{id} | auth:api,myapi | Hapus BM |
| POST | /api/business | auth:api,myapi | Single BM data |
| POST | /api/business/accounts | auth:api,myapi | Akun dalam BM |
| POST | /api/business/partner | auth:api,myapi | Agensi partner |
| POST | /api/business/rename | auth:api,myapi | Rename BM |
| POST | /api/business/check | auth:api,myapi | Validasi BM |
| POST | /api/business/ads_account_add | auth:api,myapi | Import akun ke BM |
| GET | /api/facebook/businesses/{bmId}/ad-accounts | auth:api,myapi | List ad accounts |
| POST | /api/facebook/businesses/{bmId}/import-accounts | auth:api,myapi | Import massal |
| POST | /api/facebook/ad-accounts/{accId}/update-name | auth:api,myapi | Rename akun |
| POST | /api/facebook/ad-accounts/{accId}/update-name-with-partner | auth:api,myapi | Rename + partner |
| POST | /api/facebook/ad-accounts/check-partnership | auth:api,myapi | Cek partnership |
| GET | /api/facebook/import-jobs/{jobId} | auth:api,myapi | Status import |
| GET | /api/facebook/import-jobs/{jobId}/cancel | auth:api,myapi | Batalkan import |
Langkah berikutnya