Is it because you do not specify the HTTP verb GET in the second? This is how I do it in PHP and it works great ...
I call this in my main php file ...
$ymuser = yammer_user_by_email(' myemail@test.com ');
this function is in my inc file ...
function yammer_user_by_email($email, $token = null){ global $YAMMER_ADMIN_TOKEN; $user = yammer_api_get('https://www.yammer.com/api/v1/users/by_email.json?email='.$email, $YAMMER_ADMIN_TOKEN); return $user[0]; }
All my HTTP calls are routed here, and the admin token is applied to the header ... function yammer_api_call ($ url, $ method = 'GET', $ body = '', $ token) {
if ($token == null) { if (!$_SESSION['yammer_token'] || !$_SESSION['yammer_token']->access_token->token) return false; $token = $_SESSION['yammer_token']->access_token->token; } if ($method == 'GET'){ $opts = array('http' => array( 'method' => $method, 'header' => "Host: www.yammer.com\r\n" ."Authorization: Bearer " . $token . "\r\n" ) ); }else{ $opts = array('http' => array( 'method' => $method, 'header' => "Content-Type: application/x-www-form-urlencoded\r\n" ."Host: www.yammer.com\r\n" ."Authorization: Bearer " . $token . "\r\n" ."Content-Length: " . strlen($body) . "\r\n", 'content' => $body, 'timeout' => 60 ) ); } $context = stream_context_create($opts); $resp = file_get_contents($url, false, $context);
source share