所以我用FB Graph API开发了APP。这个应用程序在指定的 Facebook 页面上写帖子。我决定需要将国家和城市的目标附加到帖子中。所以我写了这样的代码:
if( count( $DataArray ) > 0 ) {
$MessageData = null;
$AccessToken = $this->GetAccessToken();
foreach( $DataArray as $ItemArray ) {
$CleanTitle = $this->ValidateTitle( $ItemArray['title'], $NotAcceptableWords );
$GenerateMessageStr = "{$CleanTitle} - http://someutl/ID/{$Item['id']}/Feed/";
$MessageData = array (
'access_token' => $AccessToken,
'message' => $GenerateMessageStr,
'targeting' => "{'cities':'Tbilisi','countries':'Georgia'}"
);
try {
$this->FacebookObject->api("/{$this->FacebookPageId}/feed", 'POST', $MessageData);
}
catch (FacebookApiException $e) {
print_r($e);
}
}
}
但执行后,这些帖子似乎仍然是公开的,并且没有附加任何目标。