Пример #1
0
 function post_anonymous_comment($params)
 {
     if (anon_comments_allowed($params['blog_xid'])) {
         debug("[post_anonymous_comment] post_xid = " . $params['post_xid']);
         $json = '{"content":"' . $params['content'] . '",' . '"name":"' . $params['name'] . '",' . '"href":"' . $params['href'] . '",' . '"email":"' . $params['email'] . '"}';
         debug("[post_anonymous_comment] json = {$json}");
         $typepad_url = get_comments_api_url($params['post_xid']);
         $response = post_text($typepad_url, $json);
         debug("[post_anonymous_comment] Response from TP Anon Comment Endpoint = {$response}");
         //function post_text ($url, $params, $decode=1) {
     } else {
         debug("Anonymous comments aren't allowed.");
     }
 }
Пример #2
0
<html>
    <head>
        <?php 
include_once 'config.php';
// provide a post_xid just in case.
$post_xid = '6a00e5539faa3b88330120a7b004e2970b';
if (array_key_exists('xid', $_GET)) {
    $post_xid = $_GET['xid'];
} else {
    if (array_key_exists('xid', $_POST)) {
        $post_xid = $_POST['xid'];
    }
}
$user_session = new TPSession();
$anon_comments_allowed = anon_comments_allowed(BLOG_XID);
// handle comment posts...
if (array_key_exists('comment_text', $_POST)) {
    if ($user_session->is_logged_in()) {
        // This will post a comment to TypePad -- while Authenticated.
        $comment = new Comment(array('post_xid' => $post_xid, 'session' => $user_session, 'content' => $_POST['comment_text']));
    } else {
        if ($anon_comments_allowed) {
            // Post anonymously.
            $comment = new Comment(array('post_xid' => $post_xid, 'content' => $_POST['comment_text'], 'name' => $_POST['comment_name'], 'href' => $_POST['comment_href'], 'email' => $_POST['comment_email'], 'blog_xid' => BLOG_XID));
        }
    }
}
$entry = new Entry(array('xid' => $post_xid));
$favorites = $entry->favorites();
$comments = $entry->comments();
?>