| 1 | { | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | =head1 NAME | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | Net::Blogger::API::Core - Blogger API methods | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | It's very dark in here because this is a black box. | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | Net::Blogger::API::Core defined methods that correspond to the | ||||||||||||||||||||||||||||
| 14 | Blogger API. | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | It is inherited by I<Net::Blogger::Engine::Base.pm> | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =cut | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | package Net::Blogger::API::Core; | ||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 1 | $Net::Blogger::API::Core::VERSION = '1.0'; | |||||||||||||||||||||||||||
| 24 | 1 | @Net::Blogger::API::Core::ISA = qw ( Exporter ); | |||||||||||||||||||||||||||
| 25 | 1 | @Net::Blogger::API::Core::EXPORT = qw (); | |||||||||||||||||||||||||||
| 26 | 1 | @Net::Blogger::API::Core::EXPORT_OK = qw (); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 1 | ▶ | use Exporter; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =head1 Blogger API METHODS | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =head2 $pkg->getUsersBlogs() | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | Fetch the I<blogid>, I<url> and I<blogName> for each of the Blogger blogs | ||||||||||||||||||||||||||||
| 35 | the current user is registered to. | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | Returns an array ref of hashes. | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | =cut | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | sub getUsersBlogs { | ||||||||||||||||||||||||||||
| 42 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
getUsersBlogs: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | 0 | my $blogs = []; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | my $call = $self->_Client->call( | |||||||||||||||||||||||||||
| 46 | "blogger.getUsersBlogs", | ||||||||||||||||||||||||||||
| 47 | $self->_Type(string=>$self->AppKey()), | ||||||||||||||||||||||||||||
| 48 | $self->_Type(string=>$self->Username()), | ||||||||||||||||||||||||||||
| 49 | $self->_Type(string=>$self->Password()), | ||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | ($call) ? return $call->result() : return []; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =head2 $pkg->newPost(\%args) | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | Add a new post to the Blogger server. | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | Valid arguments are : | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =over 4 | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =item * | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | B<postbody> (required) | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | Scalar ref. | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =item * | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | B<publish> | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | Boolean. | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =back | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | If the length of I<postbody> exceeds maximum length allowed by the Blogger servers | ||||||||||||||||||||||||||||
| 78 | -- 65,536 characters -- currently the text will be chunked into smaller pieces are | ||||||||||||||||||||||||||||
| 79 | each piece will be posted separately. | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | Releases prior to Net::Blogger 0.85 accepted a list of arguments | ||||||||||||||||||||||||||||
| 82 | rather than a reference. Version 0.85+ are backwards compatible. | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | Returns an array containing one, or more, post ids. | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =cut | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | sub newPost { | ||||||||||||||||||||||||||||
| 89 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
newPost: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 90 | 0 | ▶ | my $args = (ref($_[0]) eq "HASH") ? shift : { @_ }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if (! $self->check_newPost($args)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 0 | return 0; | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if ($self->check_exceedsMaxLength($args)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 0 | return $self->_PostInChunks(%$args); | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | my $postbody = $args->{'postbody'}; | |||||||||||||||||||||||||||
| 101 | 0 | ▶ | my $publish = ($args->{'publish'}) ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 0 | my $call = $self->_Client->call( | |||||||||||||||||||||||||||
| 104 | "blogger.newPost", | ||||||||||||||||||||||||||||
| 105 | $self->_Type(string=>$self->AppKey()), | ||||||||||||||||||||||||||||
| 106 | $self->_Type(string=>$self->BlogId()), | ||||||||||||||||||||||||||||
| 107 | $self->_Type(string=>$self->Username()), | ||||||||||||||||||||||||||||
| 108 | $self->_Type(string=>$self->Password()), | ||||||||||||||||||||||||||||
| 109 | $self->_Type(string=>$$postbody), | ||||||||||||||||||||||||||||
| 110 | $self->_Type(boolean=>$publish), | ||||||||||||||||||||||||||||
| 111 | ); | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | return ($call) ? $call->result() : return 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | =head2 $pkg->getPost($postid) | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | Returns a hash ref, containing the following keys : userid, postid, | ||||||||||||||||||||||||||||
| 119 | content and dateCreated. | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | =cut | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | sub getPost { | ||||||||||||||||||||||||||||
| 124 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
getPost: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 125 | 0 | my $postid = shift; | |||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if (! $self->check_getPost($postid)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | 0 | return 0; | |||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 0 | my $call = $self->_Client->call( | |||||||||||||||||||||||||||
| 132 | "blogger.getPost", | ||||||||||||||||||||||||||||
| 133 | $self->_Type(string=>$self->AppKey()), | ||||||||||||||||||||||||||||
| 134 | $self->_Type(string=>$postid), | ||||||||||||||||||||||||||||
| 135 | $self->_Type(string=>$self->Username()), | ||||||||||||||||||||||||||||
| 136 | $self->_Type(string=>$self->Password()), | ||||||||||||||||||||||||||||
| 137 | ); | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 0 | ▶ | if (! $call) { return 0; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 0 | my $post = $call->result(); | |||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | # See KNOWN ISSUES | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 0 | ▶ | if ($post eq "0") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 0 | $self->LastError("Unable to locate post."); | |||||||||||||||||||||||||||
| 147 | 0 | return 0; | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 0 | return $post; | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | =head2 $pkg->getRecentPosts(\%args) | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | Fetch the latest (n) number of posts for a given blog. The most recent posts | ||||||||||||||||||||||||||||
| 156 | are returned first. | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | Valid arguments are | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | =over 4 | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | =item * | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | B<numposts> | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | Int. If no argument is passed to the method, default is 1. | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | "NumberOfPosts is limited to 20 at this time. Let me know if this | ||||||||||||||||||||||||||||
| 169 | gets annoying. Letting this number get too high could result in some | ||||||||||||||||||||||||||||
| 170 | expensive db access, so I want to be careful with it." --Ev | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | =back | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | Releases prior to Net::Blogger 0.85 accepted a list of arguments | ||||||||||||||||||||||||||||
| 175 | rather than a reference. Version 0.85+ are backwards compatible. | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | Returns true or false, followed by an array of hash refs. Each hash ref | ||||||||||||||||||||||||||||
| 178 | contains the following keys : postid,content,userid,dateCreated | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | =cut | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | sub getRecentPosts { | ||||||||||||||||||||||||||||
| 183 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
getRecentPosts: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 184 | 0 | ▶ | my $args = (ref($_[0]) eq "HASH") ? shift : { @_ }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 0 | ▶ | if (! $self->check_getRecentPosts($args)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | 0 | return (0); | |||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | my $call = $self->_Client->call( | ||||||||||||||||||||||||||||
| 191 | "blogger.getRecentPosts", | ||||||||||||||||||||||||||||
| 192 | $self->_Type(string=>$self->AppKey()), | ||||||||||||||||||||||||||||
| 193 | $self->_Type(string=>$self->BlogId()), | ||||||||||||||||||||||||||||
| 194 | $self->_Type(string=>$self->Username()), | ||||||||||||||||||||||||||||
| 195 | $self->_Type(string=>$self->Password()), | ||||||||||||||||||||||||||||
| 196 | 0 | $self->_Type(int=>$args->{'numposts'}), | |||||||||||||||||||||||||||
| 197 | ); | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 0 | ▶ | my @posts = ($call) ? (1,@{$call->result()}) : (0,undef); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | 0 | return @posts; | |||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | =head2 $pkg->editPost(\%args) | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | Update the Blogger database. Set the body of entry $postid to $body. | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | Valid arguments are : | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | =over 4 | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | =item * | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | B<postbody> (required) | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | Scalar ref or a valid filehandle. | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | =item * | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | B<postid> | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | String. I<required> | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | =item * | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | B<publish> | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | Boolean. | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | =back | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | If the length of I<postbody> exceeds maximum length allowed by the Blogger servers | ||||||||||||||||||||||||||||
| 232 | -- 65,536 characters -- currently the text will be chunked into smaller pieces are | ||||||||||||||||||||||||||||
| 233 | each piece will be posted separately. | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | Releases prior to Net::Blogger 0.85 accepted a list of arguments | ||||||||||||||||||||||||||||
| 236 | rather than a reference. Version 0.85+ are backwards compatible. | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | Returns an array containing one, or more, post ids. | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | =cut | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | sub editPost { | ||||||||||||||||||||||||||||
| 243 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
editPost: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 244 | 0 | ▶ | my $args = (ref($_[0]) eq "HASH") ? shift : { @_ }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 0 | ▶ | if (! $self->check_editPost($args)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | 0 | return 0; | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 0 | ▶ | if ($self->check_exceedsMaxLength($args)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 251 | 0 | return $self->_PostInChunks(%$args); | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 0 | my $postbody = $args->{'postbody'}; | |||||||||||||||||||||||||||
| 255 | 0 | my $postid = $args->{'postid'}; | |||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 0 | ▶ | if (($self->MaxPostLength()) && (length($$postbody) > $self->MaxPostLength())) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->MaxPostLength and length $$postbody > $self->MaxPostLength
MC/DC0%0/2
$self->MaxPostLength and length $$postbody > $self->MaxPostLength
$self->MaxPostLength
length $$postbody > $self->MaxPostLength
Truth table0%0/3
A and B
A= $self->MaxPostLengthB= length $$postbody > $self->MaxPostLength
| |||||||||||||||||||||||||||||
| 258 | 0 | return $self->_PostInChunks(%$args); | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | 0 | ▶ | my $publish = ($args->{'publish'}) ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 0 | my $ok = undef; | |||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 0 | my $call= $self->_Client->call( | |||||||||||||||||||||||||||
| 266 | "blogger.editPost", | ||||||||||||||||||||||||||||
| 267 | $self->_Type(string=>$self->AppKey()), | ||||||||||||||||||||||||||||
| 268 | $self->_Type(string=>$postid), | ||||||||||||||||||||||||||||
| 269 | $self->_Type(string=>$self->Username()), | ||||||||||||||||||||||||||||
| 270 | $self->_Type(string=>$self->Password()), | ||||||||||||||||||||||||||||
| 271 | $self->_Type(string=>$$postbody), | ||||||||||||||||||||||||||||
| 272 | $self->_Type(boolean=>$publish), | ||||||||||||||||||||||||||||
| 273 | ); | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | 0 | ▶ | ($call) ? return $call->result() : return 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | =head2 $pkg->deletePost(\%args) | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | Delete a post from the Blogger server. | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | Valid arguments are | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | =over 4 | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | =item * | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | B<postid> | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | String. I<required> | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | =item * | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | B<publish> | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | Boolean. | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | =back | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | Releases prior to Net::Blogger 0.85 accepted a list of arguments | ||||||||||||||||||||||||||||
| 301 | rather than a reference. Version 0.85+ are backwards compatible. | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | Returns true or false. | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | =cut | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | sub deletePost { | ||||||||||||||||||||||||||||
| 308 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
deletePost: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 309 | 0 | ▶ | my $args = (ref($_[0]) eq "HASH") ? shift : { @_ }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | 0 | ▶ | if (! $self->check_deletePost($args)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 312 | 0 | return 0; | |||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | 0 | my $postid = $args->{'postid'}; | |||||||||||||||||||||||||||
| 316 | 0 | ▶ | my $publish = ($args->{'publish'}) ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 0 | my $call = $self->_Client->call( | |||||||||||||||||||||||||||
| 319 | "blogger.deletePost", | ||||||||||||||||||||||||||||
| 320 | $self->_Type(string=>$self->AppKey()), | ||||||||||||||||||||||||||||
| 321 | $self->_Type(string=>$postid), | ||||||||||||||||||||||||||||
| 322 | $self->_Type(string=>$self->Username()), | ||||||||||||||||||||||||||||
| 323 | $self->_Type(string=>$self->Password()), | ||||||||||||||||||||||||||||
| 324 | $self->_Type(boolean=>$publish), | ||||||||||||||||||||||||||||
| 325 | ); | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | 0 | ▶ | ($call) ? return $call->result() : return 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | =head2 $pkg->setTemplate(\%args) | ||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | Set the body of the template matching type I<$type>. | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | <quote src = "ev"> | ||||||||||||||||||||||||||||
| 335 | template is the HTML (XML, whatever -- Blogger can output any sort | ||||||||||||||||||||||||||||
| 336 | of text). Must contain opening and closing <Blogger> tags to be | ||||||||||||||||||||||||||||
| 337 | valid and accepted. | ||||||||||||||||||||||||||||
| 338 | </quote> | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | Valid arguments are | ||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | =over 4 | ||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | =item * | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | B<template> | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | Scalar ref. I<required> | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | =item * | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | B<type> | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | String. I<required> | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | Valid types are "main" and "archiveIndex" | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | =back | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | Releases prior to Net::Blogger 0.85 accepted a list of arguments | ||||||||||||||||||||||||||||
| 361 | rather than a reference. Version 0.85+ are backwards compatible. | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | Returns true or false. | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | =cut | ||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | sub setTemplate { | ||||||||||||||||||||||||||||
| 368 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
setTemplate: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 369 | 0 | ▶ | my $args = (ref($_[0]) eq "HASH") ? shift : { @_ }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | 0 | ▶ | if (! $self->check_setTemplate($args)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 372 | 0 | return 0; | |||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | my $call = $self->_Client->call( | ||||||||||||||||||||||||||||
| 376 | "blogger.setTemplate", | ||||||||||||||||||||||||||||
| 377 | $self->_Type(string=>$self->AppKey()), | ||||||||||||||||||||||||||||
| 378 | $self->_Type(string=>$self->BlogId()), | ||||||||||||||||||||||||||||
| 379 | $self->_Type(string=>$self->Username()), | ||||||||||||||||||||||||||||
| 380 | $self->_Type(string=>$self->Password()), | ||||||||||||||||||||||||||||
| 381 | 0 | $self->_Type(string=>${$args->{'template'}}), | |||||||||||||||||||||||||||
| 382 | 0 | $self->_Type(string=>$args->{'type'}), | |||||||||||||||||||||||||||
| 383 | ); | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | 0 | ▶ | ($call) ? return $call->result() : return 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | =head2 $pkg->getTemplate(\%args) | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | Fetch the body of the template matching type I<$type>. | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | Valid types are | ||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | =over 4 | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | =item * | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | B<type> | ||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | String. I<required> | ||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | Valid types are "main" and "archiveIndex" | ||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | =back | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | Releases prior to Net::Blogger 0.85 accepted a list of arguments | ||||||||||||||||||||||||||||
| 407 | rather than a reference. Version 0.85+ are backwards compatible. | ||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | Returns a string. | ||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | =cut | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | sub getTemplate { | ||||||||||||||||||||||||||||
| 414 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
getTemplate: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 415 | 0 | ▶ | my $args = (ref($_[0]) eq "HASH") ? shift : { @_ }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | 0 | ▶ | if (! $self->check_getTemplate($args)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 418 | 0 | return 0; | |||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | my $call = $self->_Client->call( | ||||||||||||||||||||||||||||
| 422 | "blogger.getTemplate", | ||||||||||||||||||||||||||||
| 423 | $self->_Type(string=>$self->AppKey()), | ||||||||||||||||||||||||||||
| 424 | $self->_Type(string=>$self->BlogId()), | ||||||||||||||||||||||||||||
| 425 | $self->_Type(string=>$self->Username()), | ||||||||||||||||||||||||||||
| 426 | $self->_Type(string=>$self->Password()), | ||||||||||||||||||||||||||||
| 427 | 0 | $self->_Type(string=>$args->{'type'}), | |||||||||||||||||||||||||||
| 428 | ); | ||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | 0 | ▶ | ($call) ? return $call->result() : return 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | sub check_exceedsMaxLength { | ||||||||||||||||||||||||||||
| 434 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
check_exceedsMaxLength: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 435 | 0 | my $args = shift; | |||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | 0 | ▶ | if (! $self->MaxPostLength()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 438 | 0 | return 0; | |||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | 0 | ▶ | if (length(${$args->{'postbody'}}) < $self->MaxPostLength()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 442 | 0 | return 0; | |||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | 0 | return 1; | |||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | sub check_newPost { | ||||||||||||||||||||||||||||
| 449 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
check_newPost: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 450 | 0 | my $args = shift; | |||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | 0 | ▶ | if (ref($args->{'postbody'}) ne "SCALAR") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 453 | 0 | $self->LastError("You must pass postbody as a scalar reference."); | |||||||||||||||||||||||||||
| 454 | 0 | return 0; | |||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | 0 | return 1; | |||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||
| 460 | sub check_getPost { | ||||||||||||||||||||||||||||
| 461 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
check_getPost: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 462 | 0 | my $postid = shift; | |||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | 0 | ▶ | if (! $postid) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 465 | 0 | $self->LastError("You must specify a postid."); | |||||||||||||||||||||||||||
| 466 | 0 | return 0; | |||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||
| 469 | 0 | return 1; | |||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||
| 472 | sub check_getRecentPosts { | ||||||||||||||||||||||||||||
| 473 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
check_getRecentPosts: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 474 | 0 | my $args = shift; | |||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||
| 476 | 0 | ▶ | my $num = (defined $args->{'numposts'}) ? $args->{'numposts'} : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | 0 | ▶ | unless ($num =~ /^(\d+)$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 479 | 0 | $self->LastError("Argument $args->{'numposts'} isn't numeric."); | |||||||||||||||||||||||||||
| 480 | 0 | return 0; | |||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | 0 | ▶ | unless (($num >= 1) && ($num <= 20)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$num >= 1 and $num <= 20
MC/DC0%0/2
$num >= 1 and $num <= 20
$num >= 1
$num <= 20
Truth table0%0/3
A and B
A= $num >= 1B= $num <= 20
| |||||||||||||||||||||||||||||
| 484 | 0 | $self->LastError("You must specify 'numposts' as an integer between 1 and 20."); | |||||||||||||||||||||||||||
| 485 | 0 | return (0); | |||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||
| 488 | 0 | return 1; | |||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | sub check_editPost { | ||||||||||||||||||||||||||||
| 492 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
check_editPost: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 493 | 0 | my $args = shift; | |||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | 0 | ▶ | if (! $args->{'postid'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 496 | 0 | $self->LastError("You must specify a postid."); | |||||||||||||||||||||||||||
| 497 | 0 | return 0; | |||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||
| 500 | 0 | ▶ | if (ref($args->{'postbody'}) ne "SCALAR") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 501 | 0 | $self->LastError("You must pass postbody as a scalar reference."); | |||||||||||||||||||||||||||
| 502 | 0 | return 0; | |||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | 0 | return 1; | |||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||
| 508 | sub check_deletePost { | ||||||||||||||||||||||||||||
| 509 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
check_deletePost: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 510 | 0 | my $args = shift; | |||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||
| 512 | 0 | ▶ | if (! $args->{'postid'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 513 | 0 | $self->LastError("No post id."); | |||||||||||||||||||||||||||
| 514 | 0 | return 0; | |||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | 0 | return 1; | |||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||
| 520 | sub check_setTemplate { | ||||||||||||||||||||||||||||
| 521 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
check_setTemplate: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 522 | 0 | my $args = shift; | |||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||
| 524 | 0 | ▶ | if (ref($args->{'template'}) ne "SCALAR") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 525 | 0 | $self->LastError("You must pass template as a scalar reference."); | |||||||||||||||||||||||||||
| 526 | 0 | return 0; | |||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | 0 | ▶ | unless ($args->{'type'} =~ /^(main|archiveIndex)$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 530 | 0 | $self->LastError("Valid template types are 'main' and 'archiveIndex'."); | |||||||||||||||||||||||||||
| 531 | 0 | return 0; | |||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||
| 534 | # see also : The Perl Cookbook, chapter 6.15 | ||||||||||||||||||||||||||||
| 535 | 0 | ▶ | unless (${$args->{'template'}} =~ /(<Blogger>)[^<]*(?:(?! <\/?Blogger>)<[^<]*)*(<\/Blogger>)/m) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 536 | 0 | $self->LastError("Your template must contain opening and closing <Blogger> tags."); | |||||||||||||||||||||||||||
| 537 | 0 | return 0; | |||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | 0 | return 1; | |||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | sub check_getTemplate { | ||||||||||||||||||||||||||||
| 544 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
check_getTemplate: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 545 | 0 | my $args = shift; | |||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||
| 547 | 0 | ▶ | unless ($args->{'type'} =~ /^(main|archiveIndex)$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 548 | 0 | $self->LastError("Valid template types are 'main' and 'archiveIndex'."); | |||||||||||||||||||||||||||
| 549 | 0 | return 0; | |||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||
| 552 | 0 | return 1; | |||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||
| 555 | =head1 VERSION | ||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||
| 557 | 1.0 | ||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||
| 559 | =head1 DATE | ||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||
| 561 | $Date: 2005/03/26 19:29:08 $ | ||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||
| 563 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||
| 565 | Aaron Straup Cope | ||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||
| 567 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||
| 569 | L<Net::Blogger::Engine::Base> | ||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||
| 571 | L<Net::Blogger::API::Extended> | ||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||
| 573 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | Copyright (c) 2001-2005 Aaron Straup Cope. | ||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | This is free software, you may use it and distribute it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | =cut | ||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | 1 | return 1; | |||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||