-
Notifications
You must be signed in to change notification settings - Fork 3
/
ApiCalls
134 lines (119 loc) · 10.5 KB
/
ApiCalls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
* Signup:
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "username=dollbok&password=Iamstupid999");
Request request = new Request.Builder()
.url("http://localhost:3000/signup")
.post(body)
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.addHeader("Cache-Control", "no-cache")
.build();
Response response = client.newCall(request).execute();
* SignIn:
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "username=dodococo&password=Iamstupid999");
Request request = new Request.Builder()
.url("http://localhost:3000/signin")
.post(body)
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.addHeader("Cache-Control", "no-cache")
.build();
Response response = client.newCall(request).execute();
* Create Text Posts:
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\n\t\"location\":{\"type\":\"point\",\"coordinates\":[-80,25.791]},\n\t\"favors\":0,\n\t\"postText\":\"This is first post\",\n\t\"age\":0,\n\t\"posterId\":1,\n\t\"date\":1523970977506\n}");
Request request = new Request.Builder()
.url("http://localhost:3000/user/post")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmllbmRzIjpbXSwicG9zdHMiOltdLCJjcmVhdGVBdCI6IjIwMTgtMDQtMjhUMDM6MjQ6NDUuODI2WiIsInVwZGF0ZUF0IjoiMjAxOC0wNC0yOFQwMzoyNDo0Ni4wNzVaIiwiX2lkIjoiNWFlM2U5N2RiMmE2YWQxMmVmMjE5ZWU0IiwidXNlcm5hbWUiOiJkb2RvY29jbyIsInBhc3N3b3JkIjoiJDJhJDEwJGU0WkJZMzZxSUlXOGg1alVBaHA2V3V1ZUJHcEJ2bHBFREwzN21STzVTdjBpaUdFLkowV1p5IiwiaWQiOjEsIl9fdiI6MCwiaWF0IjoxNTI0ODg1ODkzfQ.1yA5Xz-p6jcc61a3qDLcTsZ_NFAmZeu3xhD7vxBd-uM")
.addHeader("Cache-Control", "no-cache")
.build();
Response response = client.newCall(request).execute();
* Create Image Posts:
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
RequestBody body = RequestBody.create(mediaType, "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"location\"\r\n\r\n{\"type\":\"point\",\"coordinates\":[-80,25.791]}\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"favors\"\r\n\r\n0\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"postText\"\r\n\r\nThis is first post\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"age\"\r\n\r\n0\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"posterId\"\r\n\r\n15\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"date\"\r\n\r\n1523970977506\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--");
Request request = new Request.Builder()
.url("http://192.168.43.120:3000/user/postimg")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW")
.addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmllbmRzIjpbXSwicG9zdHMiOltdLCJjcmVhdGVBdCI6IjIwMTgtMDQtMjlUMDQ6MTQ6MTYuMjA2WiIsInVwZGF0ZUF0IjoiMjAxOC0wNC0yOVQwNDoxNDoxNi40NTlaIiwiX2lkIjoiNWFlNTQ2OTg4MzlkZWUzNTZiYTM5YjQwIiwidXNlcm5hbWUiOiJkb2RvY29jbyIsInBhc3N3b3JkIjoiJDJhJDEwJEpRN2RRY3FYTGVhcnlZOUN3SjlqRy5YbTE2WDc2WDc3MUxkaHRaYVA4VlZ4QVhWSUxNRUFhIiwiaWQiOjE1LCJfX3YiOjAsImlhdCI6MTUyNTE0OTM1MH0.pa9uf4nqSpvo_zLDyFewd2vBFdTjWSY1ZbSSSTYw2Ew")
.addHeader("Cache-Control", "no-cache")
.addHeader("Postman-Token", "cc1cf99c-cfa6-46ef-a1ce-8f156df0aaa3")
.build();
Response response = client.newCall(request).execute();
* Fetch Posts:
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("http://192.168.43.200:3333/user/fetchPosts?lon=-80&lat=25.791")
.get()
.addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmllbmRzIjpbXSwicG9zdHMiOltdLCJjcmVhdGVBdCI6IjIwMTgtMDQtMjhUMDM6MjQ6NDUuODI2WiIsInVwZGF0ZUF0IjoiMjAxOC0wNC0yOFQwMzoyNDo0Ni4wNzVaIiwiX2lkIjoiNWFlM2U5N2RiMmE2YWQxMmVmMjE5ZWU0IiwidXNlcm5hbWUiOiJkb2RvY29jbyIsInBhc3N3b3JkIjoiJDJhJDEwJGU0WkJZMzZxSUlXOGg1alVBaHA2V3V1ZUJHcEJ2bHBFREwzN21STzVTdjBpaUdFLkowV1p5IiwiaWQiOjEsIl9fdiI6MCwiaWF0IjoxNTI0ODg1ODkzfQ.1yA5Xz-p6jcc61a3qDLcTsZ_NFAmZeu3xhD7vxBd-uM")
.addHeader("Cache-Control", "no-cache")
.build();
Response response = client.newCall(request).execute();
* Remove Posts:
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("http://localhost:3000/user/removePost/13")
.get()
.addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmllbmRzIjpbXSwicG9zdHMiOltdLCJjcmVhdGVBdCI6IjIwMTgtMDQtMjhUMDM6MjQ6NDUuODI2WiIsInVwZGF0ZUF0IjoiMjAxOC0wNC0yOFQwMzoyNDo0Ni4wNzVaIiwiX2lkIjoiNWFlM2U5N2RiMmE2YWQxMmVmMjE5ZWU0IiwidXNlcm5hbWUiOiJkb2RvY29jbyIsInBhc3N3b3JkIjoiJDJhJDEwJGU0WkJZMzZxSUlXOGg1alVBaHA2V3V1ZUJHcEJ2bHBFREwzN21STzVTdjBpaUdFLkowV1p5IiwiaWQiOjEsIl9fdiI6MCwiaWF0IjoxNTI0ODg1ODkzfQ.1yA5Xz-p6jcc61a3qDLcTsZ_NFAmZeu3xhD7vxBd-uM")
.addHeader("Cache-Control", "no-cache")
.build();
Response response = client.newCall(request).execute();
* Get User Details:
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("http://localhost:3000/user/getUserDetails/5ae2b09d21e7614842553984")
.get()
.addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1YWQ1ZjVhODNjYTAwZDI2NTgyMmQzN2QiLCJ1c2VybmFtZSI6ImRvZG9jb2NvIiwicGFzc3dvcmQiOiIkMmEkMTAkVmtKSWZNN2EvRFVYWVU2U281WUxidVpFTVJIYmtxOGlYME02ZERRRmZrZ0YweEQvME5GSzIiLCJfX3YiOjAsImlhdCI6MTUyMzk3MTc3M30.vRLv5l_lvT-yjShejRDy-Q65hKDuIqocWR8yqqPI7I8")
.addHeader("Cache-Control", "no-cache")
.build();
Response response = client.newCall(request).execute();
* Edit User:
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
RequestBody body = RequestBody.create(mediaType, "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\"picOne.png\"\r\nContent-Type: image/png\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"fname\"\r\n\r\nDeepak\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"lname\"\r\n\r\nChethan\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"dname\"\r\n\r\ndodococo\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"uname\"\r\n\r\ndodococo\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"phone\"\r\n\r\n7848948784\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"age\"\r\n\r\n21\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"bio\"\r\n\r\nEverything is nice\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"id\"\r\n\r\n15\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--");
Request request = new Request.Builder()
.url("http://192.168.43.120:3000/user/edituser/")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW")
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmllbmRzIjpbXSwicG9zdHMiOltdLCJjcmVhdGVBdCI6IjIwMTgtMDQtMjlUMDQ6MTQ6MTYuMjA2WiIsInVwZGF0ZUF0IjoiMjAxOC0wNC0yOVQwNDoxNDoxNi40NTlaIiwiX2lkIjoiNWFlNTQ2OTg4MzlkZWUzNTZiYTM5YjQwIiwidXNlcm5hbWUiOiJkb2RvY29jbyIsInBhc3N3b3JkIjoiJDJhJDEwJEpRN2RRY3FYTGVhcnlZOUN3SjlqRy5YbTE2WDc2WDc3MUxkaHRaYVA4VlZ4QVhWSUxNRUFhIiwiaWQiOjE1LCJfX3YiOjAsImlhdCI6MTUyNTE0OTM1MH0.pa9uf4nqSpvo_zLDyFewd2vBFdTjWSY1ZbSSSTYw2Ew")
.addHeader("Cache-Control", "no-cache")
.addHeader("Postman-Token", "890b1a51-0404-45b0-896d-94d9fb0da501")
.build();
Response response = client.newCall(request).execute();
* Add Friend:
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("http://localhost:3000/user/addfriend/?usr=1&frnd=3")
.get()
.addHeader("Cache-Control", "no-cache")
.addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmllbmRzIjpbXSwicG9zdHMiOltdLCJjcmVhdGVBdCI6IjIwMTgtMDQtMjlUMDQ6MTQ6MTYuMjA2WiIsInVwZGF0ZUF0IjoiMjAxOC0wNC0yOVQwNDoxNDoxNi40NTlaIiwiX2lkIjoiNWFlNTQ2OTg4MzlkZWUzNTZiYTM5YjQwIiwidXNlcm5hbWUiOiJkb2RvY29jbyIsInBhc3N3b3JkIjoiJDJhJDEwJEpRN2RRY3FYTGVhcnlZOUN3SjlqRy5YbTE2WDc2WDc3MUxkaHRaYVA4VlZ4QVhWSUxNRUFhIiwiaWQiOjE1LCJfX3YiOjAsImlhdCI6MTUyNTE0OTM1MH0.pa9uf4nqSpvo_zLDyFewd2vBFdTjWSY1ZbSSSTYw2Ew")
.addHeader("Cache-Control", "no-cache")
.build();
Response response = client.newCall(request).execute();
* Remove Friend:
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("http://localhost:3000/user/removeFriend/?usr=1&frnd=3")
.get()
.addHeader("Cache-Control", "no-cache")
.addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmllbmRzIjpbXSwicG9zdHMiOltdLCJjcmVhdGVBdCI6IjIwMTgtMDQtMjlUMDQ6MTQ6MTYuMjA2WiIsInVwZGF0ZUF0IjoiMjAxOC0wNC0yOVQwNDoxNDoxNi40NTlaIiwiX2lkIjoiNWFlNTQ2OTg4MzlkZWUzNTZiYTM5YjQwIiwidXNlcm5hbWUiOiJkb2RvY29jbyIsInBhc3N3b3JkIjoiJDJhJDEwJEpRN2RRY3FYTGVhcnlZOUN3SjlqRy5YbTE2WDc2WDc3MUxkaHRaYVA4VlZ4QVhWSUxNRUFhIiwiaWQiOjE1LCJfX3YiOjAsImlhdCI6MTUyNTE0OTM1MH0.pa9uf4nqSpvo_zLDyFewd2vBFdTjWSY1ZbSSSTYw2Ew")
.addHeader("Cache-Control", "no-cache")
.build();
Response response = client.newCall(request).execute();
* Get Friend List
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("http://localhost:3000/user/getFriendList/1")
.get()
.addHeader("Cache-Control", "no-cache")
.addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmllbmRzIjpbXSwicG9zdHMiOltdLCJjcmVhdGVBdCI6IjIwMTgtMDQtMjlUMDQ6MTQ6MTYuMjA2WiIsInVwZGF0ZUF0IjoiMjAxOC0wNC0yOVQwNDoxNDoxNi40NTlaIiwiX2lkIjoiNWFlNTQ2OTg4MzlkZWUzNTZiYTM5YjQwIiwidXNlcm5hbWUiOiJkb2RvY29jbyIsInBhc3N3b3JkIjoiJDJhJDEwJEpRN2RRY3FYTGVhcnlZOUN3SjlqRy5YbTE2WDc2WDc3MUxkaHRaYVA4VlZ4QVhWSUxNRUFhIiwiaWQiOjE1LCJfX3YiOjAsImlhdCI6MTUyNTE0OTM1MH0.pa9uf4nqSpvo_zLDyFewd2vBFdTjWSY1ZbSSSTYw2Ew")
.addHeader("Cache-Control", "no-cache")
.build();
Response response = client.newCall(request).execute();
//Settings and stuff