Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to post message with message_tags field using Graph API in PHP

I want to post message with message_tags using Graph API.

I confirmed message only post in PHP, but don't work with message_tags..

This is sample code.

---------
<?php
require_once('facebook.php');

$facebook = new Facebook(array(
  'appId'  => '127916833975***', // masked
  'secret' => 'a3271136ad68587d8e83171148f93***' // masked
));

$request_params = array('message' => mb_convert_encoding('test posting message', 'UTF-8', 'EUC-JP'));

$tags = array(
          'id' => '100000834278***', // masked
          'name' => 'MY_FRIENDS_NAME', // masked
          'offset' => 0,
          'length' => 15 // friend name length
        );

$request_params['message_tags'] = $tags;
$facebook->api('/feed', 'POST', $request_params);
?>
---------

In document message_tags field,

---------
object containing fields whose names are the indexes to where objects are 
mentioned in the message field; each field in turn is an array containing 
an object with id, name, offset, and length fields, where length is the 
length, within the message field, of the object mentioned
---------

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

Allowed scopes are read_stream and publish_stream.

like image 955
Toru Shishikura Avatar asked Dec 02 '11 02:12

Toru Shishikura


1 Answers

Apparently the message_tags can only be read via the API. Writing message_tags is not supported. See this bug report and facebook response from 11/22/2011.

like image 95
zlovelady Avatar answered Nov 13 '22 21:11

zlovelady