class FBAutopostEntity in Facebook Autopost 7
Handles publishing using a Facebook publication entity.
Hierarchy
- class \FBAutopost extends \Facebook
- class \FBAutopostEntity
Expanded class hierarchy of FBAutopostEntity
File
- fb_autopost_entity/
class/ FBAutopostEntity.php, line 11 - Handles the Entity publication.
View source
class FBAutopostEntity extends FBAutopost {
/**
* Publishes content stored in a Facebook publication entity
*
* @param FacebookPublicationEntity $publication
* The fully loaded Facebook publication entity.
* @param string $page_id
* Page id (among those already selected via UI).
* If this is present it will override the parameter destination.
* Use 'me' to publish to the user's timeline
*
* @return string
* Facebook id string for the publication. Needed to edit, or delete the
* publication.
*
* @throws FBAutopostException
* @see FBAutopost::publish()
*/
public function publishEntity(FacebookPublicationEntity $publication, string $page_id = NULL) {
// Invoke FBAutopost::publish() with the parameters from $publication.
return parent::publish(array(
'type' => $publication->type,
'params' => fb_autopost_entity_get_properties($publication),
// We need to control serialization to handle class loading
'entity' => serialize($publication),
), $page_id);
}
/**
* Deletes a publication from facebook stored in an entity.
*
* @param FacebookPublicationEntity $publication
* The fully loaded Facebook publication entity.
*
* @return boolean
* TRUE if the publication was deleted successfully.
*
* @throws FBAutopostException
* @see FBAutopost::remoteDelete()
*/
public function remoteEntityDelete(FacebookPublicationEntity $publication) {
// Get a wrapper for the entity and extract the remote ID.
$wrapper = entity_metadata_wrapper('facebook_publication', $publication);
$remote_id = $wrapper->facebook_id
->value();
// If there is a remote ID in return, then delete the associated
// publication.
if (!empty($remote_id)) {
return parent::remoteDelete($remote_id);
}
else {
throw new FBAutopostException(t('Remote ID could not be found.'), FBAutopost::missing_param, WATCHDOG_ERROR);
}
}
/**
* Edits a publication in facebook from a stored entity.
*
* @param FacebookPublicationEntity $publication
* The fully loaded Facebook publication entity
*
* @throws FBAutopostException
* @see FBAutopost::remoteEdit()
*/
public function remoteEntityEdit(FacebookPublicationEntity $publication) {
// In this case, edit means delete + publish. This has the side effect that
// the ID is not preserved.
if ($this
->remoteEntityDelete($publication)) {
return $this
->publishEntity($publication);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FBAutopost:: |
private | property | Destination for the publication. An string with the page ID or 'me'. | |
FBAutopost:: |
public | property | Privacy setting for the publications. This property is made public because the getter method will give some formatting along with the property. | |
FBAutopost:: |
private | property | Publication types as defined in Facebook documentation Contains the name of the publication and the endpoint keyed by the machine name of the publication. | |
FBAutopost:: |
private | property | Boolean indicating wether to retry the publication or not when publishing on the user's timeline if the acting user does not have a valid access token. | |
FBAutopost:: |
private | property | Stored publication type. | |
FBAutopost:: |
private | function | Throws an exception if the selected page id is not among the authorized ones. | |
FBAutopost:: |
public | function | Gets the destination to publish to | |
FBAutopost:: |
protected | function | Gets the endpoint of a publication | |
FBAutopost:: |
private static | function | Get access tokens for publishing to several Facebook Pages | |
FBAutopost:: |
public | function | Gets the reply given from Facebook when asking for user account. | |
FBAutopost:: |
public | function | Gets the privacy value. | |
FBAutopost:: |
protected | function | Gets the publication type. | |
FBAutopost:: |
public | function | Gets the session object for sugar syntax. Factory method. | |
FBAutopost:: |
protected | function | Gets the publication type. | |
FBAutopost:: |
public | function | Checks if a user has an active access token. | |
FBAutopost:: |
constant | Constant indicating error code for an icorrect parameter | ||
FBAutopost:: |
constant | Constant indicating error code for a missing dependency | ||
FBAutopost:: |
constant | Constant indicating error code for a missing parameter | ||
FBAutopost:: |
function | Publishes content in the selected pages | ||
FBAutopost:: |
protected | function | Publishes on a single destination. | |
FBAutopost:: |
protected | function | Prepares the parameters to publish to Facebook, this means settings any field or destination dependent configuration. | 6 |
FBAutopost:: |
public | function | Deletes a publication from Facebook | |
FBAutopost:: |
public | function | Edits a publication from Facebook | |
FBAutopost:: |
constant | Constant indicating error code for a SDK thrown error | ||
FBAutopost:: |
public | function | Set the destination to publish to | |
FBAutopost:: |
public | function | Sets the privacy. | |
FBAutopost:: |
public | function | Sets the retry value. | |
FBAutopost:: |
public | function | Sets the type value. | |
FBAutopost:: |
function | |||
FBAutopostEntity:: |
public | function | Publishes content stored in a Facebook publication entity | |
FBAutopostEntity:: |
public | function | Deletes a publication from facebook stored in an entity. | |
FBAutopostEntity:: |
public | function | Edits a publication in facebook from a stored entity. | 1 |