2017-04-16 31 views
1

目前,我正在关注一个我发现用于制作Android项目的网站上的教程。事情是我坚持设置API URL。如何设置API URL

这是我不清楚如何获得API的URL甚至认为作者提供的链接下载API。

顺便说一下,我在本地主机上做我的项目。该网站的

链接:

http://www.duchess-france.org/accelerometer-time-series-and-prediction-with-android-cassandra-and-spark/

API源代码的链接:

https://github.com/MiraLak/accelerometer-rest-to-cassandra

+0

你必须在服务器上安装的API。然后你会得到它的URL。 – Blady214

回答

0

它在下面链接的描述了如何设置项目:

首先,你必须开始卡桑德拉

https://github.com/MiraLak/accelerometer-rest-to-cassandra#start-cassandra

然后启动该应用程序

https://github.com/MiraLak/accelerometer-rest-to-cassandra#start-the-application

然后尝试,如果这一切工作:

https://github.com/MiraLak/accelerometer-rest-to-cassandra#use-the-api

如果你是无法发出请求,请尝试一些应用 https://www.getpostman.com/如果您按照上述链接进行操作,则可以非常轻松地将请求发送到您刚刚启动的应用程序。

在您尝试发送请求并验证它在本地主机上工作后,您必须找到本地IP地址。

我猜你的手机将会在相同网络(甚至无线),所以你得找出你的计算机的本地IP ...我想这个链接就可以了: https://www.google.com/?q=how+to+find+my+local+ip

一旦你找到你的本地IP,你必须更新URL

在您的REST API请求,更改IP地址为本地主机部分,你已经发现,即:

/POST http://localhost:8080/activity/acceleration 

将成为(如果你的本地计算机的地址是192.168.1.1

/POST http://192.168.1.1:8080/activity/acceleration 

我想这应该这样做,如果你是某个地方卡住评论。

还要注意的是8080端口可能不是你的本地网络上,甚至在个人电脑的防火墙被允许。所以这可能不会马上起作用。你将不得不谷歌了一下如何打开你的电脑上的某个端口。

最好是打开手机上的浏览器,只是在网址栏中输入:

http://localhost:8080/activity/acceleration 

(别忘了交换本地主机与本地IP地址)

若本工作你全都定了。

万一你正在使用模拟器,然后这个答案可能会帮助: Accessing localhost:port from Android emulator

+0

我已成功安装Cassandra数据库并克隆Android应用程序(https://github.com/MiraLak/AccelerometerAndroidApp) 但我坚持在启动应用程序(https://github.com/MiraLak/accelerometer-rest-to -cassandra#start-the-application)并测试api(https://github.com/MiraLak/accelerometer-rest-to-cassandra#use-the-api)。我也很好的模糊了如何获取URL,如http:// localhost:8080/activity/acceleration(是我只是创建一个文件夹名称活动,并把所有的东西放在它作为wamp服务器的WWW文件夹? ) – Kairong

+0

你有没有错误信息'gradle build && java -jar build/libs/accelerometer-rest-to-cassandra-1.0.jar'应该可以正常工作。你是否安装了Gradle? https://docs.gradle.org/current/userguide/installation.html –

+0

老实说,我不知道它是什么意思启动应用程序 gradle build && java -jar build/libs/accelerometer-rest-to-cassandra-1.0。 jar – Kairong