Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save psapir/b7a832acac03f8cbde8bf8d105c00e39 to your computer and use it in GitHub Desktop.
Save psapir/b7a832acac03f8cbde8bf8d105c00e39 to your computer and use it in GitHub Desktop.
Writing a REST Service with Cloud Pages - GET Method Secured
if not empty (@token) then
set @rows = LookupRows("Rest api authorization","AccessToken",@token)
set @rowCount = rowcount(@rows)
if @rowCount > 0 then
If @action=="get" and not empty (@entrycode) then
set @rows = LookupRows("Register","EntryCode",@entrycode)
set @rowCount = rowcount(@rows)
If @rowCount==0 then
output(v(@JsonNotFound))
endif
If @rowCount > 0 then
set @row = row(@rows,1)
set @EmailAddress = field(@row,"EmailAddress")
set @FristName = field(@row,"FirstName")
set @LastName = field(@row,"LastName")
set @phone = field(@row,"PhoneNumber")
set @Json= '{"status": "ok","data": {"EntryCode":"'
set @Json= concat(@Json,@entrycode,'","email": "',@EmailAddress)
set @Json= concat(@Json,'","firstName":"',@FristName)
set @Json= concat(@Json,'","lastName":"',@LastName)
set @Json= concat(@Json,'","phoneNumber":"',@phone,'"}')
set @Json= concat(@Json,'}')
output(v(@Json))
endif
endif
endif
If @rowCount == 0 then
set @Json= '{"Status":"error", "message":" invalid access Token"}'
output(v(@Json))
endif
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment