PHP EOL in Url ?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Bisonte
Addict
Addict
Posts: 1233
Joined: Tue Oct 09, 2007 2:15 am

PHP EOL in Url ?

Post by Bisonte »

hello, guys.

I have the following problem :

I want to generate an url that contains a list.
In the description of the API it says that single list elements have to be separated with " PHP_EOL ".

Little example :

Code: Select all

;PHP_EOL.s = #LFCR$
;PHP_EOL.s = #CR$
;PHP_EOL.s = #LF$
;PHP_EOL.s = #CRLF$
PHP_EOL.s = "\n"

NewList Part.s()
PartList.s = "&elements="

AddElement(Part()) : Part() = "Item1"
AddElement(Part()) : Part() = "Item2"
AddElement(Part()) : Part() = "Item3"

ForEach Part()
  PartList + Part() + PHP_EOL
Next

Url.s + "&elements=" + PartList
But no matter which character I define as PHP_EOL, the server will always display the message that there are no elements.

(But the url has all elements... I guess it's this separator)
Any suggestions on how I can solve the problem?
PureBasic 6.10 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
User avatar
Kiffi
Addict
Addict
Posts: 1362
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: PHP EOL in Url ?

Post by Kiffi »

Perhaps:

Code: Select all

Url.s + "&elements=" + URLEncoder(PartList)
?

Greetings ... Peter
Hygge
User avatar
Bisonte
Addict
Addict
Posts: 1233
Joined: Tue Oct 09, 2007 2:15 am

Re: PHP EOL in Url ?

Post by Bisonte »

Sorry... No luck.

If only one item is exist, also the response : no current elements...
equal if I append a "PHP_EOL" or not...
PureBasic 6.10 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: PHP EOL in Url ?

Post by #NULL »

- you've got a double '&elements=' in your resulting string Url.s. You add it to PartList first and then again to Url.
- do you have a '?' between the base url and the first parameter?
User avatar
Bisonte
Addict
Addict
Posts: 1233
Joined: Tue Oct 09, 2007 2:15 am

Re: PHP EOL in Url ?

Post by Bisonte »

the complete url is

Code: Select all

https://server.com/edit?FolderName=MyDirectory&elements=https://myfile.com/1.html\nhttps://myfile.com/2.html&secure=On
PureBasic 6.10 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
User avatar
NicTheQuick
Addict
Addict
Posts: 1227
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: PHP EOL in Url ?

Post by NicTheQuick »

Bisonte wrote:the complete url is

Code: Select all

https://server.com/edit?FolderName=MyDirectory&elements=https://myfile.com/1.html\nhttps://myfile.com/2.html&secure=On
You have to urlencode all the characters after the first "?". You can not use colons and slashes in parameters.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
mk-soft
Always Here
Always Here
Posts: 5409
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: PHP EOL in Url ?

Post by mk-soft »

Mal Probieren...

Code: Select all


Procedure.s URLEncoderParams(Params.s)
  Protected url.s
  url = Params
  url = ReplaceString(url, "\n", #LF$)
  url = ReplaceString(url, "\r", #CR$)
  url = URLEncoder(url)
  url = ReplaceString(url, ":", "%3A")
  url = ReplaceString(url, "/", "%2F")
  ProcedureReturn url
EndProcedure


Debug "https://server.com/edit?" + URLEncoderParams("FolderName=MyDirectory&elements=https://myfile.com/1.html\nhttps://myfile.com/2.html&secure=On")
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Bisonte
Addict
Addict
Posts: 1233
Joined: Tue Oct 09, 2007 2:15 am

Re: PHP EOL in Url ?

Post by Bisonte »

Sorry... All tries are ending with "No Elements in your List"

I opened a support ticket... Now I have to wait...

Thanks for your patience.
PureBasic 6.10 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
Post Reply