diff options
author | LeoColomb <leocolombaro@yahoo.fr> | 2013-04-07 14:52:52 +0400 |
---|---|---|
committer | LeoColomb <leocolombaro@yahoo.fr> | 2013-04-07 14:52:52 +0400 |
commit | 3daf6593d89c608a6660a6c0b872eeb2607548ba (patch) | |
tree | f7ca7b29ac8a4e787e3602fe5efef7a9e65e937a /sample-remote-api-call.txt | |
parent | 37d0d35407c96799a8dcdd968575d519ec2cb151 (diff) |
Fix end of line
Diffstat (limited to 'sample-remote-api-call.txt')
-rw-r--r-- | sample-remote-api-call.txt | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/sample-remote-api-call.txt b/sample-remote-api-call.txt index 57e2a89f..de2c1cc9 100644 --- a/sample-remote-api-call.txt +++ b/sample-remote-api-call.txt @@ -1,47 +1,47 @@ -<?php
-
-/*
- * YOURLS : sample file showing how to use the API
- * This shows how to tap into your YOURLS install API from *ANOTHER* server
- * not from a file hosted on the same server. It's just a bit dumb to make a
- * remote HTTP request to the server the request originates from.
- *
- * Rename to .php
- *
- */
-
-// EDIT THIS: your auth parameters
-$username = 'joe';
-$password = '123456';
-
-// EDIT THIS: the query parameters
-$url = 'http://planetozh.com/blog/'; // URL to shrink
-$keyword = 'ozh'; // optional keyword
-$format = 'json'; // output format: 'json', 'xml' or 'simple'
-
-// EDIT THIS: the URL of the API file
-$api_url = 'http://yoursite/yourls-api.php';
-
-// Init the CURL session
-$ch = curl_init();
-curl_setopt($ch, CURLOPT_URL, $api_url);
-curl_setopt($ch, CURLOPT_HEADER, 0); // No header in the result
-curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return, do not echo result
-curl_setopt($ch, CURLOPT_POST, 1); // This is a POST request
-curl_setopt($ch, CURLOPT_POSTFIELDS, array( // Data to POST
- 'url' => $url,
- 'keyword' => $keyword,
- 'format' => $format,
- 'action' => 'shorturl',
- 'username' => $username,
- 'password' => $password
- ));
-
-// Fetch and return content
-$data = curl_exec($ch);
-curl_close($ch);
-
-// Do something with the result. Here, we just echo it.
-echo $data;
-
+<?php + +/* + * YOURLS : sample file showing how to use the API + * This shows how to tap into your YOURLS install API from *ANOTHER* server + * not from a file hosted on the same server. It's just a bit dumb to make a + * remote HTTP request to the server the request originates from. + * + * Rename to .php + * + */ + +// EDIT THIS: your auth parameters +$username = 'joe'; +$password = '123456'; + +// EDIT THIS: the query parameters +$url = 'http://planetozh.com/blog/'; // URL to shrink +$keyword = 'ozh'; // optional keyword +$format = 'json'; // output format: 'json', 'xml' or 'simple' + +// EDIT THIS: the URL of the API file +$api_url = 'http://yoursite/yourls-api.php'; + +// Init the CURL session +$ch = curl_init(); +curl_setopt($ch, CURLOPT_URL, $api_url); +curl_setopt($ch, CURLOPT_HEADER, 0); // No header in the result +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return, do not echo result +curl_setopt($ch, CURLOPT_POST, 1); // This is a POST request +curl_setopt($ch, CURLOPT_POSTFIELDS, array( // Data to POST + 'url' => $url, + 'keyword' => $keyword, + 'format' => $format, + 'action' => 'shorturl', + 'username' => $username, + 'password' => $password + )); + +// Fetch and return content +$data = curl_exec($ch); +curl_close($ch); + +// Do something with the result. Here, we just echo it. +echo $data; + ?>
\ No newline at end of file |