I have two facebook apps 'A' and 'B' associated with domain_A and domain_B respectively; 'A' has activated the 'Stream post URL security' flag.
I need to post content to fanpage X using "facebook sdk 4.0 for php" from app 'B', the problem is the post only success disabling A's Stream post URL security flag; otherway FacebookRequest throws an exception:
One or more of the given URLs is not allowed by the Stream post URL security app setting. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
It makes no sense, why facebook api checks this flag in app A?
I have double check the ids and secret keys, maybe A has an open session permanently like facebook users in navigators?
This is the code:
FacebookSession::setDefaultApplication($api_id_B,api_secret_key_B);
FacebookSession::enableAppSecretProof(false);
$session = FacebookSession::newAppSession($api_id_B,api_secret_key_B);
try {
$post_id = (new FacebookRequest(
$session,
'POST',
'/' . $fanpage_id_X . '/feed',
array(
'access_token' => $fanpage_token_X,
'message' => $message_post,
'link' => $link_inside_domain_B,
'caption' => $caption_post,
'name' => $link_inside_domain_B,
'description' => $description_post,
'published' => true )
)
)->execute()->getGraphObject()->asArray();
echo 'post shared!';
} catch (FacebookRequestException $e) {
echo 'ERROR! ' . $e->getMessage();
} catch (Exception $e) {
echo 'ERROR! ' . $e->getMessage();
}
Any help will be appreciated, thanks.