Smarter included API interface method invocation request

Smarter API interface included in the Internet has become a lot and mostly packaged API for others to call. Front support cross-domain requests to GET / POST submission can be. Smarter included API interface to query the actual amount included horse God, this interface is very good to enhance the site's SEO, you can choose to call station interface, you can also use the site's API interface package into its own interface.

17516207-a7e2a2d4e4cac50f.jpeg

# Shenma API request included in a query mode #

Method: GET/POST

# # Request address

https://api.ooopn.com/collect/sm/api.php

# # Request parameters

url // domain name to be queried, without http / https (required)

# # Return parameters

code // status code, 200- query is successful, 201- did not fill in the domain name, the domain name is not included 202-

domain // domain name to be queried

num // Shenma amount included

msg // error status

Example # # call

https://api.ooopn.com/collect/sm/api.php?url=www.baidu.com

# # Return data

{

    "code": "200",

    "domain": "www.baidu.com",

    "num": "3,954"

}

# PHP call #

<?php

header("Access-Control-Allow-Origin:*");

date_default_timezone_set("PRC");

$url = $_GET['url'];

$result = file_get_contents("https://api.ooopn.com/collect/sm/api.php?url=".$url);

$arr = json_decode($result,true);

if ($arr['code']==200) {

    header("Content-Type:application/json;charset=UTF-8");

    // the amount included in the output, into $ arr [ 'num']

    echo json_encode($arr,JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);

} else {

    header("Content-Type:text/html;charset=UTF-8");

    echo $arr['msg'];

}

?>

Note: Save the above PHP code into api.php uploaded to the server, you can make your own API interface


Original and Download: https: //www.hezibuluo.com/sm-collect.html

Reproduced in: https: //www.jianshu.com/p/aae5c9980f24

Guess you like

Origin blog.csdn.net/weixin_33857679/article/details/91170997