如何设置API URL

时间:2017-04-16 08:51:10

标签: android cassandra

目前我正在关注我发现制作Android项目的网站上的教程。问题是我坚持设置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

1 个答案:

答案 0 :(得分:0)

  

以下链接中描述了如何设置项目:

首先你要开始cassandra

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/如果您按照上述链接,可以很容易地将请求发送到您刚开始的应用程序。

  

在您尝试发送请求并且您确认它在localhost上都有效之后,您必须找到您的本地IP地址。

我猜你的手机将在同一个网络上(甚至是无线网络),所以你必须找到你的计算机的本地IP ...我猜这个链接会: https://www.google.com/?q=how+to+find+my+local+ip

  

找到本地IP后,您必须更新网址

在REST API请求中,使用您找到的IP地址更改localhost部分,即:

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

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

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

我认为应该这样做,如果你被困在某个地方就发表评论。

另请注意,本地网络甚至是PC的防火墙可能不允许使用端口8080。所以这可能不会马上起作用。你需要谷歌一点关于如何在你的电脑上打开某个端口。

最好的办法就是在手机上打开浏览器,然后输入网址:

http://localhost:8080/activity/acceleration

(不要忘记将localhost与您的本地IP地址交换)

如果这项工作你已经完成了。

如果你有任何机会使用模拟器,那么这个答案可能会有所帮助: Accessing localhost:port from Android emulator