简体   繁体   English

PhP-Withings身份验证实施

[英]PhP - Withings Authentication Implementation

I'm making a web-application which run under Laravel 5, and I need to incorporate Withings user's Datas. 我正在制作一个在Laravel 5下运行的Web应用程序,我需要合并Withings用户的数据。 I read the API's doc, but I don't understand it very well. 我阅读了API的文档,但我不太了解。

What are the authentication steps, and the order? 认证步骤和顺序是什么? Have you any example in aim to help me? 您有帮助我的例子吗?

Withings seems to use OAuth1, you can find an authentication flow of the standard, which help to see the global picture, at https://oauth.net/core/1.0/#anchor9 : Withings似乎使用了OAuth1,您可以在https://oauth.net/core/1.0/#anchor9上找到该标准的身份验证流程,这有助于查看全局情况: OAuth认证流程

Their API is described at http://oauth.withings.com/en/api/oauthguide and also https://developer.health.nokia.com/api (with a request tester), but you probably already got that. http://oauth.withings.com/en/api/oauthguide以及https://developer.health.nokia.com/api (带有请求测试器)中描述了其API,但是您可能已经知道了。

There's some libraries (with the composer name) you might find interesting to use (or read to help with comprehension): 您可能会发现有一些有趣的库(带有composer名字)(或阅读以帮助理解):

Setting Up the Environment 搭建环境

I am going to assume you are starting off with a fresh Laravel 5 installation, but you can skip any of these steps if you have already done them. 我将假设您从全新的Laravel 5安装开始,但是如果您已经完成这些步骤,则可以跳过这些步骤。 First off, you are going to set some environment variables in the .env file at the root of your project. 首先,您将在项目根目录的.env文件中设置一些环境变量。 Basically, these have to do with the database configuration 基本上,这些都与数据库配置有关

APP_ENV=local
APP_DEBUG=true
APP_KEY=8wfDvMTvfXWHuYE483uXF11fvX8Qi8gC

DB_HOST=localhost
DB_DATABASE=laravel_5_authentication
DB_USERNAME=root
DB_PASSWORD=root

CACHE_DRIVER=file
SESSION_DRIVER=file

Notice the APP_ENV, DB_HOST, DB_DATABASE, DB_USERNAME, and DB_PASSWORD variables. 请注意APP_ENV,DB_HOST,DB_DATABASE,DB_USERNAME和DB_PASSWORD变量。 The APP_ENV variable tells Laravel which environment we wish to run our web application in. The rest of the database variable names are pretty obvious. APP_ENV变量告诉Laravel我们希望在哪个环境中运行Web应用程序。其余的数据库变量名称非常明显。

This is all you need to do to configure the database connection. 这是配置数据库连接所需要做的全部工作。 But how does Laravel make use of these variables? 但是Laravel如何利用这些变量? Let's examine the config/database.php file. 让我们检查config / database.php文件。 You will notice the use of the env() function. 您会注意到env()函数的使用。 For example, env('DB_HOST', 'localhost'). 例如,env('DB_HOST','localhost')。 Laravel 5 uses this function to capture variables from the $_ENV and $_SERVER global arrays, which are automatically populated with the variables you define in the .env file. Laravel 5使用此函数从$ _ENV和$ _SERVER全局数组中捕获变量,这些变量将自动使用您在.env文件中定义的变量填充。

there is whole tutorial on this have a look http://code.tutsplus.com/tutorials/using-laravel-5s-authentication-facade--cms-23461 对此有完整的教程,请看http://code.tutsplus.com/tutorials/using-laravel-5s-authentication-facade--cms-23461

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM