1 year ago
#353468
Anonim
Access token to Facebook using Mule 4
I'm trying post a message to facebook doing the call via Postman and Anypoint Studio. I'm creating the page on facebook. Now I'm trying post some message one my feed. Acccording to this documentation I should able to post my message. https://developers.facebook.com/docs/pages/publishing I got this error: HTTP CONNECT on resource 'https://graph.facebook.com:443/mypageID?fields=access_token' failed: bad request (400). But when I have exactly the same call in Postman and I'm doing the call to Facebook via postman it's working. But in Anypoint Studio it's not.
Now I have this configuration. Someone could help me ?
<http:request-config name="HTTP_Request_configuration" doc:name="HTTP Request configuration" doc:id="9f1f1efd-3cb3-4565-b5e0-59a6299a788b">
<http:request-connection protocol="HTTPS" host="graph.facebook.com" >
<http:authentication >
<oauth:client-credentials-grant-type clientId="MyClientId" clientSecret="MySecret" scopes="pages_manage_metadata,pages_read_user_content,pages_show_list,user_posts,user_likes,user_birthday,public_profile, read_insights, pages_read_engagement, pages_show_list, user_hometown, user_location, ads_read, ads_management,attribution_read,business_management, public_profile, basic_info, leads_retrieval, pages_manage_cta, pages_manage_ads, pages_manage_posts, pages_manage_engagement" tokenUrl="https://graph.facebook.com/oauth/access_token" />
</http:authentication>
</http:request-connection>
</http:request-config>
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" >
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<flow name="publishtoFBPage" doc:id="962205c2-ff3a-4c3b-b241-373725c2b98c" >
<http:listener doc:name="Listener" doc:id="57cd202a-a1e4-4375-aac5-454d04807bad" path="/fbpage" config-ref="HTTP_Listener_config">
</http:listener>
<set-variable value="#[payload.message]" doc:name="incoming PayloadSet Variable" doc:id="e437e806-528d-4de9-842e-fa5a543369c1" variableName="message" />
<http:request method="GET" doc:name="Request page-id access_token" config-ref="HTTP_Request_configuration" path="/{page-id}?fields=access_token">
<http:uri-params ><![CDATA[#[output application/java
---
{
"page-id" : "mypageID"
}]]]></http:uri-params>
<http:query-params ><![CDATA[#[output application/java
---
{
"access_token" : "myToken"
}]]]></http:query-params>
</http:request>
<logger level="INFO" doc:name="Logger" message="#[payload]" />
<set-variable value="#[payload.access_token]" doc:name="page-access-token Set Variable" variableName="page-access-token" />
<set-variable value="#[payload.id]" doc:name="Page id Set Variable" variableName="page_id" />
<http:request method="GET" doc:name="Publish to Fb Request" doc:id="8277d959-3113-4ec9-b4ec-f1c0d03b5735" config-ref="HTTP_Request_configuration" path="/{page-id}/feed">
<http:uri-params ><![CDATA[#[output application/java
---
{
"page-id" : vars.page_id
}]]]></http:uri-params>
<http:query-params ><![CDATA[#[output application/java
---
{
"message" : vars.message,
"access_token" : vars.page_access_token
}]]]></http:query-params>
</http:request>
facebook-graph-api
access-token
anypoint-studio
mule4
0 Answers
Your Answer