Saving a remote file in Cloudup by creating a URL item through POST request
-
Recently I got a Cloudup account.
I am trying to save a remote file on my server by creating a POST request for URL item by using the following code:
$username = 'username';
$password = 'password';
$req = '-d url=https://www.example.com/file/XYZ.pdf';
$header = "POST /items/url HTTP/1.1\r\n".
"Host:cloudup.com\n".
"Content-Type: application/x-www-form-urlencoded\r\n".
"User-Agent: PHP-Code\r\n".
"Content-Length: " . strlen($req) . "\r\n".
"Authorization: Basic ".base64_encode($username.':'.$password)."\r\n".
"Connection: close\r\n\r\n";
$result = '';
$fp = fsockopen ('ssl://www.cloudup.com', 443, $errno, $errstr, 30);
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$result .= fgets ($fp, 128);
var_dump($result);
}
fclose ($fp);
}As explained here: https://dev.cloudup.com/#items-create-url
But its failing due to some small error which I am not able to sort out.
Please anybody help me.
- The topic ‘Saving a remote file in Cloudup by creating a URL item through POST request’ is closed to new replies.