D
D
dmitred2016-08-19 13:47:21
PHP
dmitred, 2016-08-19 13:47:21

How to send text to VK wall php?

Good afternoon, colleagues, I can’t understand the reasons for not posting the text on the wall.
below code

$text = 'Привет мир';
       
function curl( $url ){
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
$response = curl_exec( $ch );
curl_close( $ch );
return $response;
}

$mylink = "https://api.vk.com/method/wall.post?&message=".$text."&access_token=токен";

$myjs1 = curl($mylink);

If you write some text in the place of the $text variable substitution, then it sends it, does not send the variable ...
echo $text;
Gives it out completely. I don’t understand why it’s not sent and I didn’t find a limit on the number of characters anywhere in the documentation, although I didn’t even try to send more than 300.
File encoding utf-8

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hoarywolf, 2016-08-19
@dmitred

For starters, your $text is not urlencoded

D
D', 2016-08-19
@Denormalization

We carefully study php.net/manual/ru/language.variables.scope.php
The second example is just your case. Sometimes it's good to read the documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question