A
A
Alex2015-11-16 16:38:54
PHP
Alex, 2015-11-16 16:38:54

Are transitions to a new line possible in the text when publishing through the mediatopic.post method of the Odnoklassniki API in php?

There is a "sig" parameter in the mediatopic.post method, and it cannot be formed correctly if line breaks are not removed.
It is not clear whether newline transitions are allowed in "sig"?
If the text is initially converted to urlencode($text), then it is the encoded code that is published, and not the source text itself.
Are transitions to a new line possible in the text, if so, how to do it correctly in php?
Source text example:

$text = 'Первая строка
Переход на новую строку

Еще строка через одну пустую (два перехода на новую строку)';

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vjacheslav Kanivetc, 2016-02-03
@Aleha29

Solution:
JSON does not support line wrapping in values, their appearance breaks JSON. You should replace the \n character with "\\n"
In this case, everything will work as planned
--- /original answer/
If you look at an example (for example, js sdk) https://github.com/odnoklassniki/ok-js- sdk/blob/ma...
you can see that the original strings are involved in the signature calculation, and encodeURIComponent is done when passing the same parameters. Try to do the same.
PS: Probably, the requirement with encoding will not be if you communicate with the API via POST.

O
osliktv, 2016-02-03
@osliktv

+1
if passed with line breaks the API returns an error: Invalid parameter attachment value

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question