Skip to content

Instantly share code, notes, and snippets.

@TomHAnderson
Created June 2, 2012 17:53
Show Gist options
  • Save TomHAnderson/2859348 to your computer and use it in GitHub Desktop.
Save TomHAnderson/2859348 to your computer and use it in GitHub Desktop.
Singly profile returns extra characters
<?php
namespace Singly\Model;
use Zend\Http\Client,
Zend\Json\Json,
Singly\Module;
class Singly {
public function takelogin($code) {
// Validate the access token
$http = new Client();
$http->setUri('https://api.singly.com/oauth/access_token');
$http->setMethod('POST');
$http->setParameterPost(array(
'client_id' => Module::getOption('client_id'),
'client_secret' => Module::getOption('client_secret'),
'code' => $code
));
$response = $http->send();
if (!$response->isOk()) {
die('Invalid auth token returned from server');
}
$json = Json::decode($response->getContent());
$token = $json->access_token;
// Fetch the user's profile
$http = new Client();
$http->setUri('https://api.singly.com/profiles');
$http->setMethod('GET');
$http->setParameterGet(array(
'access_token' => $token
));
$response = $http->send();
$content = $response->getContent();
print_r($content);die();
$decoded = Json::decode($json);
print_r($decoded);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment