Skip to content

Instantly share code, notes, and snippets.

@thomasbennett
Last active July 14, 2020 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasbennett/39b6ab734e0111a81fd7a6be7e0fc67f to your computer and use it in GitHub Desktop.
Save thomasbennett/39b6ab734e0111a81fd7a6be7e0fc67f to your computer and use it in GitHub Desktop.
<?php
// put the code from this section into the if/else below around line 615
// if ( in_array( $request_method, array( 'GET', 'DELETE' ) ) && ! empty( $request_data ) ) {
// this garbage code will make their API work
if ( $request_method === 'GET' && 'json' === $feed['meta']['requestFormat'] ) {
// Add content type header.
$request_headers['Content-Type'] = 'application/json';
// Encode request data.
$request_data = urlencode(json_encode( $request_data ));
file_put_contents(__DIR__ . '/log.log', $request_url . $request_data);
$request_url = $request_url . $request_data;
// otherwise do what the plugin is supposed to do
} else {
// If this is a GET or DELETE request, add request data to request URL.
if ( in_array( $request_method, array( 'GET', 'DELETE' ) ) && ! empty( $request_data ) ) {
$request_url = add_query_arg( $request_data, $request_url );
}
// If this is a PUT or POST request, format request data.
if ( in_array( $request_method, array( 'POST', 'PUT' ) ) && 'json' === $feed['meta']['requestFormat'] ) {
// Add content type header.
$request_headers['Content-Type'] = 'application/json';
// Encode request data.
$request_data = json_encode( $request_data );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment