How send text message with link in WhatsApp using what's API chat - whatsapp

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?

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', '$1', $text);
}

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

Related

Post html content to an activity with Google + Domains API

I'm triying to post HTML content to an activity with the new google + domains API with no success.
Activity activity = new Activity()
.setObject(new Activity.PlusObject().setContent("First line<br><b>second line</b>"))
.setAccess(acl);
Acording to the documentation with setConent you can specify "The HTML-formatted content, which is suitable for display." but when i try to post some html its get displayed as plain text.
I need to create an activity with some linebreaks and bold text. How can i achieve that?
Thanks in advance.
the content (HTML) field is only meant for output, you are not allowed to write in HTML. You should be writing in plain text (as you do in the browser), newlines are respected with normal line breaks (\n)
This field is useful to display formatted posts that contain links etc..

Xcode - Add hyperlink to email

In some apps you can email straight from the app. I have seen Flipboard, you can email an article to a friend and inside the email is hyperlinked text like this:
Sent via Flipboard
So it directs you to the page with a click of the text. How can I do this? I do not want to add the link as part of the message body as it is very messy and ugly... I would prefer this clickable text way.
Thanks!
The MFMailComposeViewController has a method called
setMessageBody:isHTML:.
Here the important thing is isHTML.
Doing a link in HTML is quite simple : <a href=myURL>LinkName</a>.

Passbook adding href

I'd like to create a Passbook card with a URL on the back page in one of the "Back fields". Does anyone know if it's possible to use a href entry so that I don't expose the actual URL?
For example, in the JSON record, instead of:
"value" : "Click here, http://google.com.au"
make it:
"value" : "Click here, <a href='http://google.com.au'>HERE</a>"
No you cannot, any html markup field will be parsed.
Urls are parsed automatically and must be in plain text.
#MacTeo is correct, URLs (emails, telephone numbers and addresses) will automatically become clickable, but the any HTML markup will be not be processed and you'll end up with the raw HTML visible on the back of the pass.
The best you can do right now is to get hold of a short domain and install a redirect script.
Then you can use something short but enticing such as http://wt.is/latest_offer that redirects to wherever you want.
From iOS7 on you can use the attributed_value property for this. (docs):
"attributedValue": "<a href='http://example.com/customers/123'>Edit my profile</a>"

How can i format the HTML contents of mail in iphone ?

I am using MFMailComposer for mailing.I just convert the contents of URL in a string and use that string to send mail . But the problem is that HTML file contains button link image and when i mail it gives two blank icon with the HTML page.How can i remove that icons before the mail is send.
If it is not necessary to convert URL content to string. Simply pass HTML in MFMailComposer.
But even if you want to detect the TAGs in content of URL then simply parse the whole HTML of URL and check for button(input) tag. and you can check for completed button tag also. Simply ignore the statements between starting and ending point of tags and create another HTML content.

HTML encoded links and anchors

I have a use case where I am setting the page focus to a particular element (having an anchor before it). When a user is not signed in, there is a redirect to the login page and after signing in, the user is redirected to the page in question, with the URL encoded.
I see that a URL of the form link#target works as expected (focusing on the element) while the url encoded link link%23target doesn't. Is this expected behavior?
Edit: If this is the expected behavior, is there a work around to focus on the target? As in, a way around url encode?
Edit adding more info:
Assuming that there is a code
page1.html
... html before the anchor ...
<a name="test">Some code</a>
... html after the anchor ...
I am accessing the page as page1.html%23test. This doesn't work the same way as page1.html#test. Is there a jQuery method to implement this? Would location.hash contain test even after it has been url encoded? I have no control on changing the url encoding.
Edit:
As I knew which named anchor I wanted to go to after page is redirected, I did a
window.location.hash = namedAnchor
to solve the issue. This JS line is output only if a customer is successfully signed in. Solved my issue, though not the generic answer I was looking for. I was looking for a way to avoid escaping of # in url encode.
Yes. Encoding the # as %23 effectively says "I just mean a plain old "#" character, not a URL fragment". The same is true of other reserved characters: escaping them stops them from having special meaning in the URL.
In your case you do want to encode the URL when passing it to your login page as a parameter, but your login page should decode the URL before performing the redirect.
You can both parse this string with PHP or other script language, or with JavaScript using the encodeURIComponent. I wrote an article for that, you can check on http://www.stoimen.com/blog/2009/05/25/javascript-encode-cyrillic-symbols-with-encodeuricomponent/
Hope that can help you. However despite the default behavior you must check with either method.