• 19-07-2010, 10:54:03
    #1
    Twitter.com 'a api ile bağlanarak durum güncellemesi yapan bir bileşen hazırladaım. Localhostta sorunsuz çalışmasına rağmen hostta hata alıyorum. Hata mesajı şu:

    Request Entity Too Large
    The requested resource
    /statuses/update.xml
    does not allow request data with POST requests, or the amount of data provided in the request exceeds the capacity limit.
    
    Additionally, a 413 Request Entity Too Large error was encountered while trying to use an ErrorDocument to handle the request
    Host ile ilgili olduğunu düşünüyorum ama tam olarak anlayamadım. Yani gönderilen veri boyutu sanırım host tgarafından Apache ile belirtilen stabdarrt boyuttan büyük gibi bişey diyor ama gönderdiğim sadece 140 harflik bir cümle.

    Yardımlarınızı bekliyorum.
  • 19-07-2010, 13:01:20
    #2
    Üyeliği durduruldu
    Sunucu windows mu linux mu?
  • 19-07-2010, 14:52:08
    #3
    cemoka adlı üyeden alıntı: mesajı görüntüle
    Sunucu windows mu linux mu?
    Linux.


    Ben bu bileşeni başka bir kod örneğine bakarak yaptım. O kod örneğinde şöyle bir class kullanulmış. Bu class sanırım bu hatayı almamamızı sağlıyor. Ama emin değilim.

    <?php
    
    
    class Twitter {
    
        private $auth = false;
        private $debug = false;
        public  $error = false;
    
        function __construct($user, $pass, $debug=false) {
            // Store an auth key for the HTTP Authorization: header
            $this->auth = base64_encode($user . ':' . $pass);
            $this->debug = $debug;
        }
    
        function update($new_status) {
            if (strlen($new_status) > 140) {
                $this->error = "Status too long: {$new_status}.";
                return false;
            }
            $fp = @fsockopen('twitter.com', 80, $errno, $errstr);
            if (!$fp) {
                $this->error = "Socket error #{$errno}: {$errstr}";
                return false;
            }
            $post_data = "status=" . urlencode($new_status);
            $to_send  = "POST /statuses/update.xml HTTP/1.1\r\n";
            $to_send .= "Host: twitter.com\r\n";
            $to_send .= "Content-Length: " . strlen($post_data) . "\r\n";
            $to_send .= "Authorization: Basic {$this->auth}\r\n\r\n";
            $to_send .= $post_data . "\r\n\r\n";
            $bytes = fwrite($fp, $to_send);
            if ($bytes === false) {
                $this->error = "Socket error: Error sending data.";
                return false;
            }
            elseif ($bytes < strlen($to_send)) {
                $this->error = "Socket error: Could not send all data.";
                return false;
            }
            if ($this->debug) echo "Sent:\n{$to_send}\n\n";
            $response = '';
            while (!feof($fp)) {
                $buf = fread($fp, 1024);
                if ($buf === false) {
                    $this->error = "Socket error: Error reading data.";
                    return false;
                }
                $response .= $buf;
            }
            if ($this->debug) echo "Received:\n{$response}";
            $was_error = preg_match(
                "#" .
                preg_quote("<error>") .
                "(.+)" .
                preg_quote("</error>") .
                "#i",
                $response, $matches);
            if ($was_error) {
                $this->error = "Twitter error: {$matches[1]}";
                return false;
            }
            list($first_line) = explode("\r\n", $response);
            if ($first_line != "HTTP/1.1 200 OK") {
                $this->error = "Request error: {$first_line}";
                return false;
            }
            return true;
        }
    
    }
    ?>
    Bu classın tam olarak işlevi nedir?