The Tpost method
The post method is the most crucial method of all - it posts status updates, blog posts, and micro-blog posts to Ping.fm.
Parameters
It takes four parameters:- $post_method
- The method to post with - can be "blog", "microblog", or "status".
- $body
- The body of the post.
- $title (optional)
- The title of the post - only used if
$post_methodis set to "blog". - $services (optional)
- The name of a service or an array of services to post to.
Return value
It returns a boolean, for whether the post was successful or not. An example of something un-successful would be attempting to post to a service which does not match the post method.Example usage:
This is perhaps the most basic example:
<?php
$PHPingFM = new PHPingFM($developer_key, $user_app_key);
$posted = $PHPingFM->tpost("triggerName", "Working with Ping.fm's API.");
?>
More advanced usage.
You could, for example, build a form to post to Ping.fm (since we have turned on the$debug parameter, the posts will not actually be posted anywhere).The code behind that
<?php
$PHPingFM = new PHPingFM($developer_key, $user_app_key);
if (isset($_POST['trigger']) {
$result = $PHPingFM->tpost($_POST['trigger'], $_POST['post']);
if (!$result) {
$output = '<div class="error">There was an error in posting.</div>';
}
else {
$output = '<div class="success">Post was posted successfully.</div>';
}
}
$triggers = $PHPingFM->triggers();
$trigger_select = '<select name="trigger">';
foreach ($triggers as $key => $trigger) {
$trigger_select .= '<option value ="$key">$key</option>';
}
$trigger_select .= '</select>';
print $trigger_select;
// --- The rest of the form rendering ---
?>