Changeset 9370
- Timestamp:
- 12/20/2019 08:28:52 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/class-trac.php
r9366 r9370 128 128 129 129 /** 130 * Call the Back-channel WordPress Trac API. 131 * 132 * For valid $methods to call, see: https://meta.trac.wordpress.org/browser/sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications/trac-notifications-db.php 133 */ 134 public function wpapi( $method, $args = null ) { 135 $wpapi_url = str_replace( '/login/rpc', '/wpapi/', $this->trac_uri ); 136 $wpapi_url .= '?call=' . $method; 137 138 $context = stream_context_create( [ 'http' => [ 139 'method' => 'POST', 140 'user_agent' => 'WordPress.org Trac; trac.WordPress.org', 141 'max_redirects' => 0, 142 'timeout' => 5, 143 'ignore_errors' => true, 144 'header' => [ 145 'Authorization: Basic ' . base64_encode( $this->credentials[0] . ':' . $this->credentials[1] ), 146 ], 147 'content' => http_build_query( [ 148 'secret' => TRAC_NOTIFICATIONS_API_KEY, 149 'arguments' => json_encode( $args ), 150 ] ), 151 ] ] ); 152 153 $json = file_get_contents( 154 $wpapi_url, 155 false, 156 $context 157 ); 158 159 return json_decode( $json ); 160 } 161 162 /** 130 163 * Encodes DateTime objects into the Trac Date JSON format. 131 164 */
Note: See TracChangeset
for help on using the changeset viewer.