Tagging people in wall post with POST to Facebook Graph API

11,848

See my answer here Facebook Graph API Post with_tags option

the gist of it is

I think what you want to use is just "tags" and it should just contain id's as specified here https://developers.facebook.com/docs/reference/api/user/#posts

**note you cannot do this though without also specifying a place

Facebook have now released mention tagging which might be the solution you need https://developers.facebook.com/docs/opengraph/mention_tagging/ but it requires custom open graph actions.

Share:
11,848
Logan Best
Author by

Logan Best

Updated on June 05, 2022

Comments

  • Logan Best
    Logan Best almost 2 years

    I'm having some serious trouble with tagging people in a wall post. I'm working with CakePHP right now and using the FB API to POST to the Graph API. Here's the code:

        $theMsg1 = $this->Connect->user('name').' tagged ';
        $theMsg2 = $friendName.' on the IF Tag website.';
        $msg1Len = strlen($theMsg1);
        $fbNameLen = strlen($friendName);`
    
        $fbcall = FB::api($fbID.'/feed', 'POST', array(
            'name'    => $theTag['Tag']['name'],
            'caption' => 'IF Tag is an application that allows you to interact with people on Facebook.',
            'message' => $theMsg1.$theMsg2,
            'message_tags' => array(
                $msg1Len => array(
                    'id' => $friendID,
                    'name' => $friendName,
                    'offset' => $msg1Len,
                    'length' => $fbNameLen
                ),
                'picture' => 'http://patronsocialclub.com/img/global/head/drinkmaker.gif',
                'link' => 'iftag.local'
            )
        ));
    

    From what I understand and what I've read I'm supposed to use the message_tags object to tag people in a post but it's not working at all. It doesn't give any errors, just doesn't tag.

    I've also tried using @[{userid}:1:{username}] from other posts I've seen but that doesn't seem to work with the current iteration of the API.