Tag someone on a feed dialog with Facebook API

13,585

Solution 1

Sorry, you cant tag people on feed dialog, but only the pictures using the tags param in "/photos".

The Tagging concept is available only for the Open Graph stories.

UPDATE:

You can tag a person only with a valid place parameter(if you want to hide the place in post, give any valid page id instead), the post will look something like-


enter image description here

I guess, this is the only possible solution for tagging the friends in a post if you are not using the open graph

Solution 2

FB.ui method 'feed' is the equivalent to POSTing to the /USER_ID/feed Graph API endpoint, which creates posts. And there is currently no way to create tags for posts using the api.

Ref:

https://developers.facebook.com/bugs/247911678652789

https://developers.facebook.com/docs/reference/api/post/

Alternatively, you could upload a photo to an album (or to /me/photos) and include tags for the photo:

https://developers.facebook.com/docs/reference/api/photo/ [see 'tags: create' section]

This is how I take a user uploaded file and publish it with tags:

// Upon successful file (photo) upload.
$FILEPATH = $_FILES['file']['tmp_name'];

// upload it to FB.
$args = array(
  'name' => 'Testing photo upload via php-SDK!',
  'source' => '@'.realpath($FILEPATH),
  'tags' => array(
    array('tag_uid' => USER_ID, 'x' => 20, 'y' => 40),
  )
);
$post_id = $facebook->api('/me/photos', 'post', $args);

Solution 3

Found this one here:

For example the following message would mention the Facebook Developers page inline:

Test message @[19292868552] tag

But your app must be reviewed first.

Solution 4

For the feed tagging, see my previous answers here Facebook Graph API Post with_tags option

To summarise you basically need to use mention tagging

https://developers.facebook.com/docs/technical-guides/opengraph/mention-tagging/

Solution 5

You can't tag images in a Post to the NewsFeed (/home) or a user's Wall (/feed). See the Graph API docs for Posts to feed. There is no tag-related parameter.

I'm sure i have seen this somewhere recently

What you have seen may be photo uploads, which do appear in the feed, but are not classified as posts to the newsfeed by the API. Photo uploads accept tag attributes. See Graph APi docs for Photo.

Share:
13,585
Admin
Author by

Admin

Updated on June 15, 2022

Comments

  • Admin
    Admin almost 2 years

    I'm using this code to share a picture on facebook.

    <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:fb="https://www.facebook.com/2008/fbml">
      <head>
        <title>My Feed Dialog Page</title>
      </head>
      <body>
        <div id='fb-root'></div>
        <script src='http://connect.facebook.net/en_US/all.js'></script>
        <p><a onclick='postToFeed(); return false;'>Post to Feed</a></p>
        <p id='msg'></p>
    
        <script> 
          FB.init({appId: "13899290", status: true, cookie: true});
    
          function postToFeed() {
    
            // calling the API ...
            var obj = {
              method: 'feed',
              redirect_uri: 'YOUR URL HERE',
              link: 'https://developers.facebook.com/docs/reference/dialogs/',
              picture: 'http://fbrell.com/f8.jpg',
              name: 'Facebook Dialogs',
              caption: 'Reference Documentation',
              description: 'Using Dialogs to interact with users.'
            };
    
            function callback(response) {
              document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
            }
    
            FB.ui(obj, callback);
          }
    
        </script>
      </body>
    </html>
    

    i would like to tag someone who is on the picture. How can i achieve this ?

    Thanks in advance