Closed ghost closed 11 years ago
OK, I think I've figured out what I need to know about Git, yea for new skills. Anyway I guess I don't have the rights to push into the repo (read only). Can I get access to submit potential updates?
Anyway Here is the lastest AppDotNet.php file with my changes incorporated.
CHANGES:
End of File: 2 new functions getId and getTokenStream
At Line 276
if ($this->_accessToken) {
$headers[] = 'Authorization: Bearer '.$this->_accessToken;
}
if ($params[access_token] && $act != 'post' && $act != 'delete') {
$headers[] = 'Authorization: Bearer '.$params[access_token];
}
else if ($this->_accessToken) {
$headers[] = 'Authorization: Bearer '.$this->_accessToken;
}
<?php /**
this class tries to make no assumptions at all. */ class AppDotNet {
private $_baseUrl = 'https://alpha-api.app.net/stream/0/'; private $_authUrl = 'https://alpha.app.net/oauth/';
private $_authPostParams=array();
// stores the access token after login private $_accessToken = null;
// stores the user ID returned when fetching the auth token private $_user_id = null;
// stores the username returned when fetching the auth token private $_username = null;
// The total number of requests you're allowed within the alloted time period private $_rateLimit = null;
// The number of requests you have remaining within the alloted time period private $_rateLimitRemaining = null;
// The number of seconds remaining in the alloted time period private $_rateLimitReset = null;
// debug info private $_last_request = null; private $_last_response = null;
// ssl certification private $_sslCA = null;
/**
// if the digicert certificate exists in the same folder as this file, // remember that fact for later if (file_exists(dirname(FILE).'/DigiCertHighAssuranceEVRootCA.pem')) { $this->_sslCA = dirname(FILE).'/DigiCertHighAssuranceEVRootCA.pem'; } }
/**
// construct an authorization url based on our client id and other data $data = array( 'client_id'=>$this->_clientId, 'response_type'=>'code', 'redirect_uri'=>$callback_uri, );
$url = $this->_authUrl.'authenticate?'.$this->buildQueryString($data); if ($scope) { $url .= '&scope='.implode('+',$scope); }
// return the constructed url return $url; }
/**
// construct the necessary elements to get a token
$data = array(
'client_id'=>$this->_clientId,
'client_secret'=>$this->_clientSecret,
'grant_type'=>'authorization_code',
'redirect_uri'=>$callback_uri,
'code'=>$_GET['code']
);
// try and fetch the token with the above data
$res = $this->httpReq('post',$this->_authUrl.'access_token', $data);
// store it for later
$this->_accessToken = $res['access_token'];
$this->_username = $res['username'];
$this->_user_id = $res['user_id'];
}
// return what we have (this may be a token, or it may be nothing) return $this->_accessToken; }
/**
/**
// construct the necessary elements to get a token $data = array( 'client_id'=>$this->_clientId, 'client_secret'=>$this->_clientSecret, 'grant_type'=>'client_credentials', );
// try and fetch the token with the above data $res = $this->httpReq('post',$this->_authUrl.'access_token', $data);
// store it for later $this->_accessToken = $res['access_token']; $this->_username = null; $this->_user_id = null;
return $this->_accessToken; }
/**
/**
/**
/**
$response = explode("\r\n\r\n",$response,2); $headers = $response[0]; if (isset($response[1])) { $content = $response[1]; } else { $content = null; }
// this is not a good way to parse http headers // it will not (for example) take into account multiline headers // but what we're looking for is pretty basic, so we can ignore those shortcomings $headers = explode("\r\n",$headers); foreach ($headers as $header) { $header = explode(': ',$header,2); if (count($header)<2) { continue; } list($k,$v) = $header; switch ($k) { case 'X-RateLimit-Remaining': $this->rateLimitRemaining = $v; break; case 'X-RateLimit-Limit': $this->rateLimit = $v; break; case 'X-RateLimit-Reset': $this->rateLimitReset = $v; break;
}
} return $content; }
/\
/\
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
public function getLastRequest() { return $this->_last_request; } public function getLastResponse() { return $this->_last_response; }
}
class AppDotNetException extends Exception {}
You just need to create your own fork. Then you can commit changes to your own repo and send pull requests to jdolitsky.
Hi,
I am right now going to learn how to properly do a pull request so I can do this properly but in case I fail..
I've been trying to get back in line with AppDotNetPHP proper before the Streaming stuff but I've made a couple of small changes since last syncing up.
Mostly I added two functions:
getId, which is an API supported way to get an ID (user object) when you only know the username.
getTokenStream, this is a way to pass in a token other than the authed users to get a different stream.
This was in order to make @teawithcarls "View Accounts" work with Appeio. In order to get this to work I also had to changed httpReq slightly. I realize this is a bit specific but not too bad..
I think that's the only diffs.
Trying out SmartGit and some other softwares.