Skip to content

Commit 60254db

Browse files
authored
Small updates to network API and rebranding for REST tutorial (coronalabs#60)
* Rebranding * Changed sample website * Fixed sample address * Updated hostURL sample address * Replaced broken sample image link * Updated sample code for the new image file * Small changes * Removed branding * Replaced branding with constants
1 parent ec9cfd6 commit 60254db

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

markdown/api/library/network/canDetectNetworkStatusChanges.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ local function networkListener( event )
3030
end
3131

3232
if ( network.canDetectNetworkStatusChanges ) then
33-
network.setStatusListener( "www.coronalabs.com", networkListener )
33+
network.setStatusListener( "www.solar2d.com", networkListener )
3434
else
3535
print( "Network reachability not supported on this platform." )
3636
end

markdown/api/library/network/cancel.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,18 @@ local function networkListener( event )
6363

6464
if ( event.isError ) then
6565
print( "Network error: ", event.response )
66-
elseif ( event.phase == "began" ) and ( event.bytesEstimated > 1000000 ) then
66+
elseif ( event.phase == "began" ) and ( event.bytesEstimated > 80000 ) then
6767
print( "Canceling request, file is too big!" )
6868
network.cancel( event.requestId )
6969
end
7070
end
7171

7272
-- Start the image download
7373
network.download(
74-
"http://www.coronalabs.com/demo/hello.png",
74+
"https://plugins.solar2d.com/images/logo-banner.png",
7575
"GET",
7676
networkListener,
7777
{ progress = true },
78-
"helloCopy.png",
78+
"bannerCopy.png",
7979
system.TemporaryDirectory )
8080
``````

markdown/api/library/network/download.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This function returns a handle that can be passed to [network.cancel()][api.libr
2424

2525
## Gotchas
2626

27-
You cannot execute a network download during an `applicationSuspend` or `applicationExit` [event][api.event.system.type]. After Corona suspends, no callbacks will fire. You can work around this by saving the request you wish to make to a file upon suspension. Then, on an `applicationResume` [event][api.event.system.type], check if there is a pending download saved and, if so, execute it.
27+
You cannot execute a network download during an `applicationSuspend` or `applicationExit` [event][api.event.system.type]. When your application suspends, no callbacks will fire. You can work around this by saving the request you wish to make to a file upon suspension. Then, on an `applicationResume` [event][api.event.system.type], check if there is a pending download saved and, if so, execute it.
2828

2929
Network requests do not raise runtime errors in the event of failure so there is no need to wrap them in a Lua `pcall()` statement (errors are reported in the event sent to the network listener).
3030

@@ -102,7 +102,7 @@ network.download(
102102
"GET",
103103
networkListener,
104104
params,
105-
"helloCopy.png",
105+
"maskCopy.png",
106106
system.TemporaryDirectory
107107
)
108108
``````

markdown/api/library/network/request.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Makes an asynchronous HTTP or HTTPS request to a URL. This function returns a ha
2020

2121
## Gotchas
2222

23-
* You cannot execute a network request during an `applicationSuspend` or `applicationExit` [event][api.event.system.type]. After Corona suspends, no callbacks will fire. You can work around this by saving the request you wish to make to a file upon suspension. Then, on an `applicationResume` [event][api.event.system.type], check if there is a pending request saved and, if so, execute it.
23+
* You cannot execute a network request during an `applicationSuspend` or `applicationExit` [event][api.event.system.type]. When your application suspends, no callbacks will fire. You can work around this by saving the request you wish to make to a file upon suspension. Then, on an `applicationResume` [event][api.event.system.type], check if there is a pending request saved and, if so, execute it.
2424

2525
* The `Content-Type` of requests defaults to `text/plain`. If you're `POST`-ing form data, you must set it appropriately <nobr>(see the [example](#HTTP_POST_with_custom_headers) below).</nobr>
2626

@@ -89,7 +89,7 @@ Note that if a `filename` table is specified in `params.body` or in `params.resp
8989
``````lua
9090
-- The following sample code contacts Google's encrypted search over SSL
9191
-- and prints the response (in this case, the HTML source of the home page)
92-
-- to the Corona terminal.
92+
-- to the console.
9393

9494
local function networkListener( event )
9595

@@ -171,7 +171,7 @@ params.progress = "download"
171171

172172
-- Tell network.request() that we want the output to go to a file:
173173
params.response = {
174-
filename = "corona.jpg",
174+
filename = "solar.jpg",
175175
baseDirectory = system.DocumentsDirectory
176176
}
177177

markdown/api/library/network/setStatusListener.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Starts monitoring a host for its network reachability status. This API is design
3030
network.setStatusListener( hostURL, listener )
3131

3232
##### hostURL ~^(required)^~
33-
_[String][api.type.String]._ The host you want to monitor. This may be something like `"www.coronalabs.com"`. You should not include `http://` or the port number.
33+
_[String][api.type.String]._ The host you want to monitor. This may be something like `"www.solar2d.com"`. You should not include `http://` or the port number.
3434

3535
##### listener ~^(required)^~
3636
_[Listener][api.type.Listener]._ The listener that gets [networkStatus][api.event.networkStatus] events for the specified host. Pass `nil` to unregister the listener that's set for the specified host.

markdown/api/library/network/upload.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This function returns a handle that can be passed to [network.cancel()][api.libr
2222

2323
## Gotchas
2424

25-
You cannot execute a network upload during an `applicationSuspend` or `applicationExit` [event][api.event.system.type]. After Corona suspends, no callbacks will fire. You can work around this by saving the request you wish to make to a file upon suspension. Then, on an `applicationResume` [event][api.event.system.type], check if there is a pending upload saved and, if so, execute it.
25+
You cannot execute a network upload during an `applicationSuspend` or `applicationExit` [event][api.event.system.type]. When your application suspends, no callbacks will fire. You can work around this by saving the request you wish to make to a file upon suspension. Then, on an `applicationResume` [event][api.event.system.type], check if there is a pending upload saved and, if so, execute it.
2626

2727
Network requests do not raise runtime errors in the event of failure so there is no need to wrap them in a Lua `pcall()` statement (errors are reported in the event sent to the network listener).
2828

markdown/tutorial/social/connectREST/index.markdown

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Connecting to REST API Services
33

4-
One of the "hidden" powers of Corona is the ability to connect to various online services to get data into your app. To accomplish this, a popular option is __REST__ (or&nbsp;RESTful) APIs which are based on standard HTTP protocols and are generally easy to authenticate.
4+
Using CORONA_CORE_PRODUCT, you can connect to various online services to get data into your app. To accomplish this, a popular option is __REST__ (or&nbsp;RESTful) APIs which are based on standard HTTP protocols and are generally easy to authenticate.
55

66

77
## REST Overview
@@ -26,15 +26,15 @@ Let's inspect this in more detail:
2626

2727
* Following this is typically the category of functionality. In this example, all of Twitter's "friends" APIs are grouped under the `/friends` family.
2828

29-
* Finally, the specific `/list` API will fetch a list of the current user's friends, conveniently formatted in JSON which is easily compatible with Corona (alternatively,&nbsp;some services allow you to request XML data by specifying `.xml` instead of&nbsp;`.json`).
29+
* Finally, the specific `/list` API will fetch a list of the current user's friends, conveniently formatted in JSON which is easily compatible with CORONA_CORE_PRODUCT (alternatively,&nbsp;some services allow you to request XML data by specifying `.xml` instead of&nbsp;`.json`).
3030

3131

3232
## Authentication
3333

3434
Most REST APIs require some form of verification or authentication, in particular if you're trying to add or update data. Authentication can occur in various ways, for example by passing the username and password as part of the domain name:
3535

3636
``````
37-
http://username:[email protected]/someapi/dosomething.json
37+
https://username:[email protected]/someapi/dosomething.json
3838
``````
3939

4040
In this example, the `username:password` method is a shortcut to using a headers table. Sometimes the username and password will be referred to as the "API&nbsp;Key" and "secret" and they may need to be encoded in some fashion such as [MD5][api.library.crypto].
@@ -44,7 +44,7 @@ An alternate method is to use a __headers__ table, discussed in more detail belo
4444

4545
## Making API Calls
4646

47-
In Corona, your REST API calls are made via [network.request()][api.library.network.request]. For this API, you provide a URL, an HTTP "verb," a callback function to handle the completed request, and an optional table of information in which to handle headers and data passed to the server.
47+
Your REST API calls are made via [network.request()][api.library.network.request]. For this API, you need to provide a URL, an HTTP "verb", a callback function to handle the completed request, and an optional table of information in which to handle headers and data passed to the server.
4848

4949
### Basic Request
5050

0 commit comments

Comments
 (0)