How to realize Wechat Jump to wap external browser Interface
This article introduces the knowledge of "how to implement Wechat Jump to wap external browser Interface". In the operation of practical cases, many people will encounter this dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
What is the function of Wechat jumping to an external browser?
General links are opened in Wechat and can only be viewed in Wechat's browser. But Wechat jumps to the external browser interface of wap, which can open a user-specified link in Wechat, and then evoke the opening of a web page in a mobile browser other than Wechat, breaking away from the restrictions of Wechat.
How to do it?
1. Get the interface.
2. Fill in the URL that needs to be redirected to a browser outside Wechat.
3. After you get the address, you can share and promote it.
The above are some personal experience sharing, shortcomings are welcome to correct, interested friends can also leave messages for exchange and discussion!
Here is a piece of code for your reference:
Php
$url = "http://api.monkeyapi.com";
$params = array (
'appkey' = >' appkey',// the APPKEY you applied for
'path' = >' / routes to be switched by home',// (optional)
);
$paramstring = http_build_query ($params)
$content = Curl ($url, $paramstring)
$result = json_decode ($content, true)
If ($result) {
Var_dump ($result)
} else {
/ / request exception
}
/ * *
* request the returned content of the API
* @ param string $url [requested URL address]
* @ param string $params [requested parameters]
* @ param int $ipost [whether to use POST format]
* @ return string
, /
Function Curl ($url, $params = false, $ispost = 0)
{
$httpInfo = array ()
$ch = curl_init ()
Curl_setopt ($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1)
Curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 60)
Curl_setopt ($ch, CURLOPT_TIMEOUT, 60)
Curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true)
Curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true)
If ($ispost) {
Curl_setopt ($ch, CURLOPT_POST, true)
Curl_setopt ($ch, CURLOPT_POSTFIELDS, $params)
Curl_setopt ($ch, CURLOPT_URL, $url)
} else {
If ($params) {
Curl_setopt ($ch, CURLOPT_URL, $url.'?'.$params)
} else {
Curl_setopt ($ch, CURLOPT_URL, $url)
}
}
$response = curl_exec ($ch)
If ($response = FALSE) {
/ / echo "cURL Error:" Curl_error ($ch)
Return false
}
$httpCode = curl_getinfo ($ch, CURLINFO_HTTP_CODE)
$httpInfo = array_merge ($httpInfo, curl_getinfo ($ch))
Curl_close ($ch)
Return $response
}
This is the end of the content of "how to realize Wechat Jump to wap external browser Interface". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!