Facebook: message posted with PHP SDK not sent to twitter

一曲冷凌霜 提交于 2020-01-25 06:42:05

问题


I an facing an issue with the Facebook SDK POST action when posting a very basic message on my page which is linked to my Twitter account. I have tried to solve the issue by myself using Google and StackOverflow, but I didn't manage to find a fix.

The issue is the following:

When I post a message with the SDK:

  • It appears in the page and is visibe by myself
  • It appears in the page also for other Facebook user
  • It appears in the Facebook Feed
  • but the message is not transmitted to my Twitter account

When it post something "manually" it is correctly sent to my Twitter account. The issue only appears when using the SDK. Hereafter you can find my code and the context of my request:

  • I am using a PHP script on my personal desktop (WAMP server).
  • The attachement is very very basic: 'message' => "Hello dear followers!"
  • The application used to post is not in sandbox mode.
  • Your app detail page has not yet been submitted for review.
  • The message appears as public on the page and is indeed visible by other users.
  • When I post manually the exact same message, it is correctly sent to Twitter.

Can you help me with this issue? Many thanks and all the best.

$appid = *(hidden)*;
$appsecret =  *(hidden)*;
$pageId=  *(hidden)*;
$facebook = new Facebook(array('appId' => $appid,'secret' => $appsecret,'cookie' => false));
$user = $facebook->getUser();

if($user){

    try{

        $page_info = $facebook->api("/$pageId?fields=access_token");

        if (!empty($page_info['access_token'])){

            $attachment = array(

            'access_token' => $page_info['access_token'],
            'message' => "Hello dear followers!",
            'actions' => json_encode(array('name' => $action_name,'link' => $action_link))

            );

            $status = $facebook->api("/$pageId/feed", "post", $attachment);

        }

    }

}

回答1:


The issue appears because of the special action item:

'actions' => json_encode(array('name' => $action_name,'link' => $action_link)) 

Removing this specificity the message is transmitted to Twitter, successfully.



来源:https://stackoverflow.com/questions/16645586/facebook-message-posted-with-php-sdk-not-sent-to-twitter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!