| @@ 65-72 (lines=8) @@ | ||
| 62 | } |
|
| 63 | ||
| 64 | // Kind of annoying. Maybe refactor Jetpack_Signature to handle body-hashing |
|
| 65 | if ( is_null( $body ) ) { |
|
| 66 | $body_hash = ''; |
|
| 67 | } else { |
|
| 68 | if ( !is_string( $body ) ) { |
|
| 69 | return new Jetpack_Error( 'invalid_body', 'Body is malformed.' ); |
|
| 70 | } |
|
| 71 | $body_hash = jetpack_sha1_base64( $body ); |
|
| 72 | } |
|
| 73 | ||
| 74 | $auth = array( |
|
| 75 | 'token' => $token_key, |
|
| @@ 80-85 (lines=6) @@ | ||
| 77 | } |
|
| 78 | ||
| 79 | $required_parameters = array( 'token', 'timestamp', 'nonce', 'method', 'url' ); |
|
| 80 | if ( !is_null( $body ) ) { |
|
| 81 | $required_parameters[] = 'body_hash'; |
|
| 82 | if ( !is_string( $body ) ) { |
|
| 83 | return new Jetpack_Error( 'invalid_body', 'Body is malformed.' ); |
|
| 84 | } |
|
| 85 | } |
|
| 86 | ||
| 87 | foreach ( $required_parameters as $required ) { |
|
| 88 | if ( !is_scalar( $$required ) ) { |
|