Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 通过URL方案共享到电报的链接_Html_Web_Url Scheme - Fatal编程技术网

Html 通过URL方案共享到电报的链接

Html 通过URL方案共享到电报的链接,html,web,url-scheme,Html,Web,Url Scheme,我想通过URL方案为电报共享链接 我创造了这个: tg://msg?text = www.example.com?t=12 链接打开了电报,但没有其他事情发生 我对Viber使用了相同的代码,它可以工作: viber://forward?text = www.example.com?t=12 它将在Viber中打开一条新消息,其中包含以下文字: www.example.com 换句话说,它削减了我的URL 有什么想法吗?PHP <a href="tg://msg?text=<?p

我想通过URL方案为电报共享链接

我创造了这个:

tg://msg?text = www.example.com?t=12
链接打开了电报,但没有其他事情发生

我对Viber使用了相同的代码,它可以工作:

viber://forward?text = www.example.com?t=12
它将在Viber中打开一条新消息,其中包含以下文字:

www.example.com

换句话说,它削减了我的URL

有什么想法吗?

PHP

<a href="tg://msg?text=<?php echo rawurlencode($gotoURL); ?>">Link</a>


JavaScript

<script>TEXT="any text or url";</script>

<a onclick="window.location='tg://msg?text='+encodeURIComponent(TEXT);">Link</a>
TEXT=“任何文本或url”;
链接
这对我很有用:

tg://msg?text=Mi_mensaje&to=+1555999

您还可以使用telegram.me共享链接,如果设备上未安装telegram应用程序,该链接将返回到Webgram


https://telegram.me/share/url?url=&text=

要检查电报是否已安装,可以执行以下操作(从ShareKit的Whatsapp共享模块借用):

iOS检查是否安装了任何可以处理tg://方案的应用程序,即电报。

有关电报共享:

目标C:

if([UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tg://msg?text=test"]){
 [UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tg://msg?text=test"]
}else{
 //App not installed.
}
Swift 3.0:

let urlString = "tg://msg?text=test"
let tgUrl = URL.init(string:urlString.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)!)
if UIApplication.shared.canOpenURL(tgUrl!)
    {
        UIApplication.shared.openURL(tgUrl!)
    }else
    {
       //App not installed.
    }
如果您使用了canOpenURL,则需要添加到info.plist中

<key>LSApplicationQueriesSchemes</key>
<array>
   <string>tg</string>
</array>
LSApplicationQueriesSchemes
甘油三酯

尝试使用tg://share

<a href="tg://share?url=www.example.com?t=12&text=Check out this url">Link</a>

您有以下URL选项

https://t.me/share/url?url={url}&text={text}
https://telegram.me/share/url?url={url}&text={text}
tg://msg_url?url={url}&text={text}
如果您想确认,以下是官方API源:

如果您有兴趣观看跟踪这些URL的项目,请查看我们!:


刚刚测试过,这样,在未安装的情况下,它既可以打开电报应用程序,也可以打开浏览器:

let webURL = NSURL(string: "https://t.me/<YOUR ID>")!
UIApplication.shared.open(webURL as URL)
让webURL=NSURL(字符串:https://t.me/")!
UIApplication.shared.open(webURL作为URL)

您可以使用链接
telegram.me
,该链接将提供一个预览页面,其中包含请求在应用程序中打开链接的警报

https://telegram.me/share/url?url=<URL>&text=<TEXT>
https://telegram.me/share/url?url=&text=

第二个选项是直接调用应用程序链接:

tg://msg_url?url=<url>&text=<encoded-text>
tg://msg\u url?url=&text=
我特别喜欢第二个选项,它也适用于桌面应用程序


可能您使用localhost,因此它不显示共享。在live host中试用它


<a href = "https://telegram.me/share/url?url=<URL>&text=<TEXT>">Telegram</a>

有了这个,我们可以打开xdg的电报,如果我们选择contact,默认情况下,发送文本将出现在message字段中。

如何检查安装的IStelGram?在swiftcan中,我们可以打开telegram,开始与所选的bot(不是数字)聊天,例如tg://msg?text=Mi_mensaje&to=@my_bot@QadirHussain要打开电报以开始与bot聊天,请使用类似“”的url。它会将您重定向到与该机器人的聊天屏幕。我们是否可以打开telegram以开始与所选机器人(不是数字)的聊天,例如tg://msg?text=HI there&to=@my_bot@Qadir侯赛因,你找到解决办法了吗?联系人添加在电话联系人中,我使用tg://msg?text=hi&to=+91XX,然后ios重定向到用户聊天屏幕,在android中我怎么办?@Maulikpatel这对android@QadirHussain应该有帮助,它会将我重定向到电报,但不是特定的用户聊天屏幕。@Maulikpatel不知道android中的这一点
<a href = "https://telegram.me/share/url?url=<URL>&text=<TEXT>">Telegram</a>