From: Nicolas LÅ“uillet Date: Tue, 16 Feb 2016 06:55:18 +0000 (+0100) Subject: Added developer documentation X-Git-Tag: 2.0.0-beta.2~10^2~11 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=b6321bed7b8b8ba34e23a3d0c048f7d05ab309bf;p=github%2Fwallabag%2Fwallabag.git Added developer documentation --- diff --git a/src/Wallabag/CoreBundle/Controller/DeveloperController.php b/src/Wallabag/CoreBundle/Controller/DeveloperController.php index 3cb86881..edbcec4b 100644 --- a/src/Wallabag/CoreBundle/Controller/DeveloperController.php +++ b/src/Wallabag/CoreBundle/Controller/DeveloperController.php @@ -12,6 +12,8 @@ class DeveloperController extends Controller * @param Request $request * * @Route("/developer", name="developer") + * + * @return \Symfony\Component\HttpFoundation\Response */ public function indexAction(Request $request) { @@ -22,6 +24,8 @@ class DeveloperController extends Controller * @param Request $request * * @Route("/developer/client/create", name="create_client") + * + * @return \Symfony\Component\HttpFoundation\Response */ public function createClientAction(Request $request) { @@ -33,6 +37,19 @@ class DeveloperController extends Controller return $this->render('WallabagCoreBundle:Developer:client.html.twig', array( 'client_id' => $client->getPublicId(), + 'client_secret' => $client->getSecret(), )); } + + /** + * @param Request $request + * + * @Route("/developer/howto/first-app", name="howto-firstapp") + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function howtoFirstAppAction(Request $request) + { + return $this->render('WallabagCoreBundle:Developer:howto_app.html.twig'); + } } diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/client.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/client.html.twig index edebc7ee..5ab35700 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/client.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/client.html.twig @@ -1,9 +1,24 @@ {% extends "WallabagCoreBundle::layout.html.twig" %} -{% block title %}{% trans %}New client{% endtrans %}{% endblock %} +{% block title %}{% trans %}New application{% endtrans %}{% endblock %} {% block content %} +
+
+
- Client ID: {{ client_id }} +
+

My application parameters

+

Here are your application parameters.

+
    +
  • Client ID: {{ client_id }}
  • +
  • Client Secret: {{ client_secret }}
  • +
+ Back to Developer main page +
+ +
+
+
{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/howto_app.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/howto_app.html.twig new file mode 100644 index 00000000..2db15b16 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/howto_app.html.twig @@ -0,0 +1,68 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title %}{% trans %}How to create my first application{% endtrans %}{% endblock %} + +{% block content %} +
+
+
+ +
+

The following commands make use of the HTTPie library. Make sure it is installed on your system before using it.

+

You need a token to communicate between your 3rd application and wallabag API.

+

To create this token, you need to create a new client.

+

Now, create your token (replace client_id, client_secret, username and password with the good values):

+

+ +

+http POST http://v2.wallabag.org/oauth/v2/token \
+    grant_type=password \
+    client_id=12_5um6nz50ceg4088c0840wwc0kgg44g00kk84og044ggkscso0k \
+    client_secret=3qd12zpeaxes8cwg8c0404g888co4wo8kc4gcw0occww8cgw4k \
+    username=yourUsername \
+    password=yourPassw0rd
+                        
+ +

+

The API will return a response like this:

+

+ +

+HTTP/1.1 200 OK
+Cache-Control: no-store, private
+Connection: close
+Content-Type: application/json
+Date: Tue, 06 Oct 2015 18:24:03 GMT
+Host: localhost:8000
+Pragma: no-cache
+X-Debug-Token: be00a1
+X-Debug-Token-Link: /profiler/be00a1
+X-Powered-By: PHP/5.5.9-1ubuntu4.13
+{
+    "access_token": "ZWFjNjA3ZWMwYWVmYzRkYTBlMmQ3NTllYmVhOGJiZDE0ZTg1NjE4MjczOTVlNzM0ZTRlMWQ0MmRlMmYwNTk5Mw",
+    "expires_in": 3600,
+    "refresh_token": "ODBjODU1NWUwNmUzZTBkNDQ5YWVlZTVlMjQ2Y2I0OWM2NTM1ZGM2M2Y3MDhjMTViM2U2MzYxYzRkMDk5ODRlZg",
+    "scope": null,
+    "token_type": "bearer"
+}
+                        
+ +

+

The access_token is useful to do a call to the API endpoint. For example:

+

+ +

+http GET http://v2.wallabag.org/api/entries.json \
+    "Authorization:Bearer ZWFjNjA3ZWMwYWVmYzRkYTBlMmQ3NTllYmVhOGJiZDE0ZTg1NjE4MjczOTVlNzM0ZTRlMWQ0MmRlMmYwNTk5Mw"
+                        
+ +

+

This call will return all the entries for your user.

+

If you want to see all the API endpoints, you can have a look to our API documentation.

+

Back to Developer main page

+
+ +
+
+
+{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/index.html.twig index 9e06005f..36d5c2bd 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Developer/index.html.twig @@ -3,7 +3,31 @@ {% block title %}{% trans %}Developer{% endtrans %}{% endblock %} {% block content %} +
+
+
+ +
+

Welcome to the wallabag API

+ +

Documentation

+ + + +

My applications

+ + +
+ +
+
+
- Create a new client {% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Static/quickstart.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Static/quickstart.html.twig index aff8dd2b..6c786951 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Static/quickstart.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Static/quickstart.html.twig @@ -28,6 +28,10 @@
  • {% trans %}Migrate from Pocket{% endtrans %}
  • {% trans %}Migrate from wallabag v1{% endtrans %}
  • +

    {% trans %}Developers{% endtrans %}

    +

    {% trans %}Full documentation{% endtrans %}