4 * YOURLS : sample file showing how to use the API
\r
7 // EDIT THIS: your auth parameters
\r
9 $password = '123456';
\r
11 // EDIT THIS: the query parameters
\r
12 $url = 'http://planetozh.com/caca'; // URL to shrink
\r
13 $keyword = 'caca'; // optional keyword
\r
14 $format = 'json'; // output format: 'json', 'xml' or 'simple'
\r
16 // EDIT THIS: the URL of the API file
\r
17 $api_url = 'http://127.0.0.1/ozh.in/yourls-api.php';
\r
19 // Init the CURL session
\r
21 curl_setopt($ch, CURLOPT_URL, $api_url);
\r
22 curl_setopt($ch, CURLOPT_HEADER, 0); // No header in the result
\r
23 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return, do not echo result
\r
24 curl_setopt($ch, CURLOPT_POST, 1); // This is a POST request
\r
25 curl_setopt($ch, CURLOPT_POSTFIELDS, array( // Data to POST
\r
27 'keyword' => $keyword,
\r
28 'format' => $format,
\r
29 'username' => $username,
\r
30 'password' => $password
\r
33 // Fetch and return content
\r
34 $data = curl_exec($ch);
\r
37 // Do something with the result. Here, we just echo it.
\r