简体   繁体   English

在facebook上分享链接

[英]Share link in facebook post

i have this simple php code to post message on the facebook wall 我有这个简单的PHP代码在Facebook墙上发布消息

require_once('facebook.php');

try {
    $facebook = new Facebook(FB_APIKEY, FB_SECRET);

    $facebook->api_client->session_key = FB_SESSION;

    $attachment = array(
        'message' => 'some meesgae',
        'name' => 'This is my demo Facebook application!',
        'caption' => "Caption of the Post",
        'link' => 'mylink.com',
        'description' => 'this is a description',
        'actions' => array(array(
                     'name' => 'Get Search', 
                     'link' => 'google.com'
                  ))
    );

    $result = $facebook->api('/me/feed?access_token=' . FB_SESSION, 
              'post', 
              $attachment);

     var_dump($result);

But i cant see any share link appears on the post on the FB wall. 但我看不到FB墙上的帖子上出现任何共享链接。

Can anyone tell me how to add the share link on my post in FB wall Thanks 任何人都可以告诉我如何在FB墙上的帖子中添加共享链接谢谢

i have a question, did you figure out how to do this? 我有一个问题,你有没有弄清楚如何做到这一点? when posting just a staus without image or link i see the share link on the post but when sending image or link it isn't, i found a solution for link by puting it inside the message but still have the problem with image. 当发布一个没有图像或链接的状态时我看到帖子上的共享链接但是当发送图像或链接时它不是,我找到了一个链接的解决方案,将它放在消息中但仍然有图像问题。

for the link you can use : 您可以使用以下链接:

$attachment = array(
  'access_token'  => $page_info['access_token'],
  'message'       => "some text here \n\n {mylinkpersonal}"
)

Like Jimmy Sawczuk commented you seem to use an old version of the Facebook PHP SDK, you should update to the latest version . 就像Jimmy Sawczuk评论你似乎使用旧版本的Facebook PHP SDK一样,你应该更新到最新版本

Another thing it's that I don't think you need to specify an access token when using the PHP SDK. 另一件事是我认为在使用PHP SDK时不需要指定access token

$result = $facebook->api('/me/feed', 'POST', $attachment);

There is an example in the Facebook documentation on how to " Post a link to a User's wall using the Graph API ". Facebook文档中有一个例子,说明如何“ 使用Graph API发布用户墙的链接 ”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM