In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "how to use php to call URL short link API interface". In the operation of actual cases, many people will encounter such a 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!
instructions
Interface address: http://api.monkeyapi.com
Request method: http get/post
Return format: json
JSON returns examples {"code": 200, "msg": "success", "data": "http://t.cn/ELuxjqk"}php$url =" http://api.monkeyapi.com";$params = array ('appkey' = >' appkey',// the APPKEY'url' = > 'www.monkeyapi.com',// you applied for); $paramstring = http_build_query ($params); $content = Curl ($url, $paramstring); $result = json_decode ($content, true) If ($result) {var_dump ($result);} else {/ / request exception} / * request API return content * @ param string $url [requested URL address] * @ param string $params [requested parameter] * @ param int $ipost [whether in POST form] * @ 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 } pythonaccountsUSRABING www.monkeyapi.com: python #-*-coding: utf-8-*-import json, urllibfrom urllib import urlencodeurl = "http://api.monkeyapi.com"params = {" appkey ":" appkey ", # APPKEY" url ":" www.monkeyapi.com ", # websites to be queried} params = urlencode (params) f = urllib.urlopen (url) Params) content = f.read () res = json.loads (content) if res: print (res) else: print ("request exception") FAQ
1. Is the monkey data interface stable?
A: monkey data is returned in real time using the official interface, with high accuracy, large concurrency and a stability rate of 99.999%.
2. What amount of request?
Answer: the process in which the user requests the interface address once through the program, and the interface returns a result (short link) is called a request, and the number of requests for short links is called the number of requests.
3. What does the frequency of requests mean?
A: the request frequency is the time it takes to wait when you request to detect the first short link and then request the second short link. For example, the frequency is 2 seconds, that is, the interval between two requests must be 2 seconds. It is recommended that users use unlimited frequency interface and real-time cyclic request detection when there are many links.
4. Can I request short link interfaces in batches?
A: monkey data short link api API supports batch real-time detection, and users can cycle real-time batch requests through scheduled scripts.
This is the end of the introduction of "how to call the URL short link API interface with php". 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!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.