Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ericmann
Last active August 29, 2015 14:28
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 ericmann/f4da442171ffc83f263b to your computer and use it in GitHub Desktop.
Save ericmann/f4da442171ffc83f263b to your computer and use it in GitHub Desktop.
Temporary Test Code
/**
* Gets the PURL from the Friendbuy API.
*
* @param string e-mail address
* @returns object API Response
*/
function friendbuy_get_purl( $email ) {
// Verify param is actually an e-mail
if ( ! is_email( $email ) ) {
error_log( 'friendbuy-api.php: Not a valid e-mail' );
return;
}
$id = 'f54f761c-secret';
$pass = get_theme_mod( 'friendbuy-secret-key', false );
if ( ! $pass ) {
// error_log( 'friendbuy-api.php: No saved API password' );
// return;
}
$data = array(
'email' => $email,
'campaign' => array( 'id' => 16175 )
);
$args = array(
'method' => 'POST',
'headers' => array(
'Content-Type' => 'application/json'
// 'Authorization' => 'Basic ' . base64_encode( $id . ':' . $pass )
),
'timeout' => 15,
'sslverify' => false,
'body' => json_encode( $data ),
);
$fb_api_url = 'https://' . $id . ':' . $pass . '@api.friendbuy.com/v1/referral_codes';
error_log( $fb_api_url );
$response = wp_remote_post( $fb_api_url, $args );
error_log( print_r( $response, true ) );
return $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment