如何使用Ubuntu online account API创建微博HTML5申请书
在这篇文章中。我们将使用Ubuntu SDK提供online account API来訪问微博的API并显示所须要的内容。这篇文章的重点是展示怎样在HTML 5中使用online account API。我们将创建一个简单的HTML 5应用。我们终于显示的画面例如以下:
很多其它关于HTML5应用开发的资料能够在地址:https://developer.ubuntu.com/en/apps/html-5/
我们还是像曾经一样使用我们的Ubuntu SDK来创建一个最主要的weibo HTML 5应用。
这样我们就创建了一个最主要的weibo HTML 5应用。
你能够使用热键Ctrl + R来执行它尽管它并不能做什么事。
我们能够參考来对online account API有更深的了解。为了可以訪问。须要创建例如以下的文件:
1)weibo.application
<?xml version="1.0" encoding="UTF-8"?> <application> <description>Weibo scope</description> <desktop-entry>weibo.ubuntu_weibo.desktop</desktop-entry> <services> <service id="html5-weibo.ubuntu_html5weibo"> <description>Watch your favorite Weibo messages</description> </service> </services> </application>
2)weibo.service
>
<service>
<type>sharing</type>
<name>Weibo scope</name>
<icon>html5-weibo.png</icon>
<provider>html5-weibo.ubuntu_account-plugin</provider>
<translations>unity-scope-weibo</translations>
</service><strong>
</strong>
3)创建一个plugin文件文件夹并在它的以下创建
a)Main.qml, 它的内容为:
import Ubuntu.OnlineAccounts.Plugin 1.0
OAuthMain {}
b) qml-weibo.ubuntu_plugin.provider,它的内容为:
<?xml version="1.0" encoding="UTF-8"?
>
<provider>
<name>Weibo</name>
<icon>weibo.png</icon>
<translations>unity-scope-weibo</translations>
<plugin>generic-oauth</plugin>
<domains>.*weibo\.com</domains>
<single-account>true</single-account>
<template>
<group name="auth">
<setting name="method">oauth2</setting>
<setting name="mechanism">web_server</setting>
<group name="oauth2">
<group name="web_server">
<setting name="Host">api.weibo.com</setting>
<setting name="AuthPath">oauth2/authorize</setting>
<setting name="TokenPath">oauth2/access_token</setting>
<setting name="RedirectUri">https://api.weibo.com/oauth2/default.html</setting>
<setting name="ResponseType">code</setting>
<setting name="ClientId">Your developer key</setting>
<setting type="as" name="AllowedSchemes">['https','http']</setting>
<setting name="ClientSecret">Your developer secret</setting>
<setting name="ForceClientAuthViaRequestBody" type="b">true</setting>
</group>
</group>
</group>
</template>
</provider>
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/67219.html