1

I want to upload a file through photobucket API using Php but the timestamp error arises .. This is my Code

<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
session_start();
require_once('PBAPI.php');
require_once ('./helper/xmltoarray.php');
require_once ('./helper/curl.php');
require_once('OAuth/Request.php');
require_once('OAuth/Consumer.php');
require_once('OAuth/Signature/hmac_sha1.php');
if ($_FILES["file"]["error"] > 0) {
    echo '<p class="error">Error' . $_FILES["file"]["error"] . '</p>';
    exit;
}
//else {
//
//}
//if ((($_FILES["file"]["type"] == "image/gif")
//        || ($_FILES["file"]["type"] == "image/jpeg")
//        || ($_FILES["file"]["type"] == "image/pjpeg"))
//        && ($_FILES["file"]["size"] < 25000)) {
//    if ($_FILES["file"]["error"] > 0) {
//        echo "Error: " . $_FILES["file"]["error"] . "<br />";
//    }
else {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Stored in: " . $_FILES["file"]["tmp_name"];
    if (!move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"])) {

        echo '<p class="error">Some Error is occured in Uploading the file</p>';
        exit;
    }
    try {
        $path = dirname(__FILE__) . '\\upload\\'. $_FILES["file"]["name"];
        echo $path;
        $key = 'xxxxxxxx';
        $sec = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
        $api = new PBAPI($key, $sec);
        $api->setOAuthToken($_SESSION['oauth_token'], $_SESSION['oauth_secret']);
        $api->setResponseParser('simplexml');
        $response = $api->album('temp')->upload(array('type' => 'image', 'uploadfile' => '@'.$path, 'title' => 'my upload'))->post();
        var_dump($response);
        // $data = $response['content']['result']['primary']['media'];
    } catch (PBAPI_Exception_Response $e) {
        //echo "RESPONSE $e";
    } catch (PBAPI_Exception $e) {
        //echo "EX $e";
    }
}
?>

the response is given below.i dont know why it is giving this error.Everything is perfectly fine in code

<response>
    <status>Exception</status>
    <message>Authentication failed timestamp invalid -1319642824</message>
    <code>7</code>
    <format>xml</format>
    <method>POST</method>
    <timestamp>1319642824</timestamp>
</response>
<!-- den3ws194 @ Wed, 26 Oct 2011 09:27:04 -0600 -->

please anyone who can tell me what could be the problem..

Sharpzain120
  • 365
  • 3
  • 9
  • 18
  • Note that your script blindly uses the user-provided filename for storing the upload. That name can be ANYTHING, and include path information. Your script allows the remote user to scribble on any file on the server that the webserver process has access to. – Marc B Oct 26 '11 at 16:05
  • [Photobucket's API FAQ](http://partneryahoo.photobucket.com/developer/forum?read,2,2,2,quote=1) - Apparently this is a pretty common question for them. – Mr. Llama Oct 26 '11 at 16:06
  • @GigaWatt I had seen this but none of the mentioned problem present in my code – Sharpzain120 Oct 26 '11 at 16:11

0 Answers0