Skip to content

Instantly share code, notes, and snippets.

@mbijon
Last active August 29, 2015 14:01
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 mbijon/16ac667c746ad949549c to your computer and use it in GitHub Desktop.
Save mbijon/16ac667c746ad949549c to your computer and use it in GitHub Desktop.
Test code & results: Tugboat Yards API + WordPRess HTTP API
=== Whooo PLACEMENTS ===
array(5) {
["headers"]=> array(7) {
["content-type"]=> string(16) "application/json"
["date"]=> string(29) "Fri, 23 May 2014 04:32:20 GMT"
["server"]=> string(20) "nginx/1.4.6 (Ubuntu)"
["strict-transport-security"]=> string(16) "max-age=31536000"
["x-forwarded-proto"]=> string(5) "https"
["content-length"]=> string(3) "469"
["connection"]=> string(5) "Close"
}
["body"]=> string(469) "
{"placements": [
{"placement_id": 1948849, "target_id": 646, "spec": "p160x160", "target_type": "offer"},
{"placement_id": 1692189, "target_id": 168, "spec": "p300x400", "target_type": "project"},
{"placement_id": 1745236, "target_id": 168, "spec": "p300x400", "target_type": "project"},
{"placement_id": 1826429, "target_id": 168, "spec": "p300x200", "target_type": "project"},
{"placement_id": 1878063, "target_id": 168, "spec": "p300x400", "target_type": "project"}
]}"
["response"]=> array(2) {
["code"]=> int(200)
["message"]=> string(2) "OK"
}
["cookies"]=> array(0) { }
["filename"]=> NULL
}
=== Whooo CODE ===
array(5) {
["headers"]=> array(7) {
["content-type"]=> string(10) "text/plain"
["date"]=> string(29) "Fri, 23 May 2014 04:32:20 GMT"
["server"]=> string(20) "nginx/1.4.6 (Ubuntu)"
["strict-transport-security"]=> string(16) "max-age=31536000"
["x-forwarded-proto"]=> string(5) "https"
["content-length"]=> string(3) "242"
["connection"]=> string(5) "Close"
}
["body"]=> string(242) " "
["response"]=> array(2) {
["code"]=> int(200)
["message"]=> string(2) "OK"
}
["cookies"]=> array(0) { }
["filename"]=> NULL
}
<?php
$url_placements = 'https://api.tugboatyards.com/placements';
$url_code = 'https://api.tugboatyards.com/placements/code';
$args = array(
'headers' => array(
'X-Tugboat-Auth' => '######################'
)
);
$placements = wp_remote_get( $url_placements, $args );
echo '=== Whooo PLACEMENTS ===<br />';
var_dump( $placements );
$code = wp_remote_get( $url_code, $args );
echo '<br /><br />=== Whooo CODE ===<br />';
var_dump( $code );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment