Created
August 30, 2010 04:56
-
-
Save meancode/557026 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$username = 'namehere'; | |
$password = 'passhere'; | |
$url = '<$mt:EntryPermalink$>'; // This would be for Movable Type | |
$format = 'simple'; | |
$api_url = 'http://domain.com/yourls-api.php'; | |
$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, | |
'format' => $format, | |
'action' => 'shorturl', | |
'username' => $username, | |
'password' => $password | |
)); | |
$data = curl_exec($ch); | |
curl_close($ch); | |
echo $data; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment