0

I am using WhatsApp chat in PHP to send messages. From my PHP script everything work fine, but the URL inside the text message doesn't render as a clickable link. It is shown as plain text instead.

$Msg= "hello !. \N http://example.com ";

What am I doing wrong?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Mona alawfi
  • 97
  • 2
  • 11
  • May be this answer will help me. http://stackoverflow.com/questions/26365363/sending-hyeprlink-text-through-whatsapp-api-php . – Mona alawfi Oct 10 '15 at 06:34
  • Refer the Website https://phrkrish.wordpress.com/2016/07/18/share-video-image-text-through-an-ios-app-in-whatsapp/ – HariKrishnan.P Jul 21 '16 at 06:11

2 Answers2

0

Your PHP variable is seen as plain text because is a pure string, nothing more. Your goal is to let be clickable that link and I guess it will be shown in a webpage. In this case, you should put some HTML code inside that variable.

Starting from your code, a valid solution can be this:

$Msg= "hello !. \N <a href='http://example.com "'>Click Here</a>;

Otherwise, you can implement this function:

    function make_links_clickable($text){
    return preg_replace('!(((f|ht)tp(s)?://)[-a-zA-Zа-яА-Я()0-9@:%_+.~#?&;//=]+)!i', '<a href="$1">$1</a>', $text);
}
Istorn
  • 485
  • 1
  • 5
  • 23
-4

use some domain mapping for your link..IP will came as plain text

Anoop
  • 1
  • Please expand your answer. It's sort of hinting around the correct answer but isn't very clear and doesn't really offer anything actionable to the original poster. – blm Oct 31 '15 at 20:22