Open the API in a window with appropriate params and headers instead of using the Curl. User is navigated to Facebook login OAuth screen. On successful login, listen on window object for message where event listener returns data in its callback function.
Sample code to listen to event data:
window.addEventListener(‘message’,
function(e) {
if (e.data && e.data.page === ‘social_media_posting’) {
const { actionType, page, platform, placement, accountId, reconnectAccounts } = e.data
}
},
false)
Event Data Response:
{
actionType: string, Ex: “close”
page: string, Ex: “social-media-posting”
platform: string, Ex: “facebook”
placement: string, Ex: “placement”
accountId: string, Ex: “658a9b6833b91e0ecb8f3958”
reconnectAccounts: string[]] Ex: [“658a9b6833b91e0ecb834acd”, “efd2daa9b6833b91e0ecb8f3511”]
}
The accountId retrieved from above data can be used to fetch Facebook account details using below API -
API: ‘/social-media-posting/oauth/facebook/accounts/:accountId’
Method: GET
GET https://services.leadconnectorhq.com/social-media-posting/oauth/facebook/start
Autorización
Bearer token generado desde el portal Leadway. Ver Autenticación .
Version
string
default: "2021-07-28"
required
Versión de la API.
Query parameters
locationId
string
default: "w37swmmLbA02zgqKPpxITe2"
required
Account Account Id
userId
string
default: "u37swmmLbA02zgqKPpxITe2"
required
User ID
page
string
default: "integration"
Facebook Page
Reconnect boolean as string
Respuestas
200 - Successful Response
422 - Unprocessable Entity
Ejemplo
curl -X GET 'https://services.leadconnectorhq.com/social-media-posting/oauth/facebook/start' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Version: 2021-07-28'
const response = await fetch ( 'https://services.leadconnectorhq.com/social-media-posting/oauth/facebook/start' , {
method: 'GET' ,
headers: {
Authorization: `Bearer ${ process . env . LEADWAY_TOKEN } ` ,
Version: '2021-07-28' ,
},
});
const data = await response . json ();
import os, requests
response = requests.request(
'GET' ,
'https://services.leadconnectorhq.com/social-media-posting/oauth/facebook/start' ,
headers = {
'Authorization' : f "Bearer { os.environ[ 'LEADWAY_TOKEN' ] } " ,
'Version' : '2021-07-28' ,
},
)
data = response.json()
<? php
$ch = curl_init ( 'https://services.leadconnectorhq.com/social-media-posting/oauth/facebook/start' );
curl_setopt_array ( $ch , [
CURLOPT_RETURNTRANSFER => true ,
CURLOPT_CUSTOMREQUEST => 'GET' ,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv ( 'LEADWAY_TOKEN' ),
'Version: 2021-07-28' ,
],
]);
$data = json_decode ( curl_exec ( $ch ), true );