PHP 美味的查询功能

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 美味的查询功能相关的知识,希望对你有一定的参考价值。

<?php

/**
 * Delicious_query();
 * @author: Stephane P. Pericat
 * @date: 2009-12-14
 * 
 * @param : $credentials(array), $request(string)
 * @return: simpleXML object
 */
function delicious_query($credentials = array(), $request) {
    if(empty($credentials)) {
        throw new InvalidArgumentException("no credentials provided");
    }
    
    $username = $credentials["username"];
    $password = $credentials["password"];
    $base_url = "https://".$username.":".$password."@api.del.icio.us/v1/";
    $full_url = $base_url.$request;
    
    $ch = curl_init($full_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $query = curl_exec($ch);
    curl_close($ch);
    
    return simplexml_load_string($query);
}

$creds = array("username" => "your_username",
               "password" => "your_password");

$query = delicious_query($creds, "posts/all?tag=php");
var_dump($query);

以上是关于PHP 美味的查询功能的主要内容,如果未能解决你的问题,请参考以下文章

美味的_测试.php

[SCOI 2016] 美味

在美味的视图中暴露“虚拟”字段?

bzoj 4571 [Scoi2016]美味——主席树

[SCOI2016]美味(可持久化线段树)

LibreOJ #2016. 「SCOI2016」美味