This commit is contained in:
Alex Grintsvayg 2017-01-30 15:19:31 -05:00
parent 8d0c394d59
commit 4849c5b370
4 changed files with 62 additions and 25 deletions

View file

@ -90,7 +90,7 @@ class Controller
$router->get('/roadmap', 'ContentActions::executeRoadmap');
$router->get('/developer-program', 'AcquisitionActions::executeDeveloperProgram');
$router->post('/developer-program', 'AcquisitionActions::executeDeveloperProgramRedirect');
$router->post('/developer-program/post', 'AcquisitionActions::executeDeveloperProgramPost');
$router->get('/developer-program/callback', 'AcquisitionActions::executeDeveloperProgramGithubCallback');
$router->get(['/press-kit.zip', 'press-kit'], 'ContentActions::executePressKit');

View file

@ -57,7 +57,7 @@ class AcquisitionActions extends Actions
return ['acquisition/developer-program', $vars];
}
public static function executeDeveloperProgramRedirect()
public static function executeDeveloperProgramPost()
{
$walletAddress = trim(Request::getPostParam('wallet'));
Session::set(static::SESSION_KEY_DEVELOPER_CREDITS_WALLET_ADDRESS, $walletAddress);
@ -71,9 +71,14 @@ class AcquisitionActions extends Actions
}
else
{
if (!Config::get('github_developer_credits_client_id'))
{
throw new Exception('no github client id');
}
$githubParams = [
'client_id' => Config::get('github_developer_credits_client_id'),
'redirect_uri' => 'http://localhost:8000/developer-program/callback',
'redirect_uri' => Request::getHostAndProto() . '/developer-program/callback',
'scope' => 'user:email',
'allow_signup' => false
];
@ -86,7 +91,8 @@ class AcquisitionActions extends Actions
{
$code = Request::getParam('code');
$walletAddress = Session::get(static::SESSION_KEY_DEVELOPER_CREDITS_WALLET_ADDRESS);
if (!$walletAddress || !$code)
if (!$walletAddress)
{
Session::set(static::SESSION_KEY_DEVELOPER_CREDITS_ERROR, 'Your wallet address disappeared while authenticated with GitHub.');
}
@ -133,7 +139,8 @@ class AcquisitionActions extends Actions
*/
Session::set(static::SESSION_KEY_DEVELOPER_CREDITS_SUCCESS,
'Send credits to GitHub user ' . $userResponseData['login'] . ' (' . $userResponseData['email'] . ') at wallet address ' . $walletAddress);
'Send credits to GitHub user ' . $userResponseData['login'] . ' (' . $userResponseData['email'] . ') at wallet address ' .
$walletAddress);
}
}
}

View file

@ -10,7 +10,7 @@
<p>
We will store your GitHub username and email address, but nothing else.
</p>
<form method="POST" action="/developer-program" class="form-inset">
<form method="POST" action="/developer-program/post" class="form-inset">
<h3 style="margin-top: 0">Receive Credits</h3>
<?php if ($error): ?>
<div class="notice notice-error spacer1"><?php echo $error ?></div>

View file

@ -61,11 +61,41 @@
<p>
To verify the LBRY daemon is running correctly and responding to requests, run:
</p>
<pre><code>curl --data "{ method: 'status' }" http://localhost:5279/lbryapi
(add response when this works)</code></pre>
<pre><code>curl 'http://localhost:5279/lbryapi' --data '{"method":"status","params":[]}'
[
{
"connection_status": {
"message": "No connection problems detected",
"code": "connected"
},
"is_first_run": false,
"is_running": true,
"blocks_behind": 0,
"startup_status": {
"message": "Started lbrynet",
"code": "started"
},
"lbry_id": "7J75jSuxU9eizREuxk1r"
}
]</code></pre>
<p>This makes it easy to interact with the LBRY API in the programming language of your choice. Here's another example:</p>
<pre><code>curl --data "{ method: 'resolve_name', params: [{ name: "what"}] }" http://localhost:5279/lbryapi
(add response when this works)</code></pre>
<pre><code>curl 'http://localhost:5279/lbryapi' --data '{"method":"resolve_name","params":[{"name":"what"}]}'
[
{
"ver": "0.0.3",
"description": "What is LBRY? An introduction with Alex Tabarrok",
"license": "LBRY inc",
"title": "What is LBRY?",
"author": "Samuel Bryan",
"language": "en",
"sources": {
"lbry_sd_hash": "d5169241150022f996fa7cd6a9a1c421937276a3275eb912790bd07ba7aec1fac5fd45431d226b8fb402691e79aeb24b"
},
"content_type": "video\/mp4",
"nsfw": false,
"thumbnail": "https:\/\/s3.amazonaws.com\/files.lbry.io\/logo.png"
}
]</code></pre>
<p>LBRY can be used to build everything from a censorship-proof image host, to a store for 3D printing files, to distribute large files or datasets, or use cases even we can't imagine!</p>
<p><a class="btn-alt" href="http://lbryio.github.io/lbry/api/">View Full API Documentation</a></p>
</section>
@ -73,8 +103,8 @@
<h3 id="credits">4. Getting Credits</h3>
<p>Many actions, such as reserving a name or purchasing paid content, require credits.</p>
<p>To receive credits, first generate a wallet address:</p>
<pre><code>curl --data "{ method: 'wallet_new_address' }" http://localhost:5279/lbryapi
I am a response</code></pre>
<pre><code>curl 'http://localhost:5279/lbryapi' --data '{"method":"wallet_new_address","params":[]}'
["bbFxRyWCFRkA9YcuuZD8nE7XTLUxYnddTs"]</code></pre>
<p>Use this address to get credits in one of two ways:</p>
<div class="row-fluid">
<div class="span6">