send url with parameters in the Whatsapp api

Asked

Viewed 809 times

-1

I need to pass a url with a variable through the Whatsapp api:

$id='3';
$link = "clique neste link para validar sua conta site.com.br/usuario.php?id=$id";

 header("Location: http://api.whatsapp.com/send?1=pt_BR&phone=55{$whatsapp}&text={$link}");

In the case of the above code, it does not pass the $id variable by the link and I need it to pass.. the link would have to go to whatsapss this way:

"clique neste link para validar sua conta site.com.br/usuario.php?id=3"

but arrives at Whatsapp so:

 "clique neste link para validar sua conta site.com.br/usuario.php?id"

if I send the variable this way it passes:

 "clique neste link para validar sua conta site.com.br/$id>" a variável vai para o whatsapp, mas se eu coloco completo não vai. 

Does anyone know if there’s another way to do it?

2 answers

0

see the link https://www.w3schools.com/tags/ref_urlencode.asp

See the link above for the character codes:

= is %3D

Space is %20

& is 26 %

among others...

Your line:

"click on this link to validate your site.com.br/user.php account? id=3"

Typing thus Zap will put the "=" and the "3".

"click on this link to validate your site.com.br/user.php account? id%3D3"

0

Try concatenating the string using the ..

$link = "clique neste link para validar sua conta site.com.br/usuario.php?id=" . $id;

If the error persists, run the function echo to check that the string is being created correctly.

echo $link

If it is being created correctly, it is valid to analyze whether the Whatsapp API filters some input information.

  • it ignores the equal sign, does not let go to the link, with all the tests I did it stopped at id when it had a =sign. I think there is no solution

  • when it comes to double quotes the best way to use the verdader is this way $link = "click this link to validate your site.com.br/user.php account? id={$id}"; why double quotes interpret php code other than single quotes

Browser other questions tagged

You are not signed in. Login or sign up in order to post.