Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Error when Upload file to twitter = chunk method #253

Closed
vitqst opened this issue Nov 9, 2017 · 0 comments
Closed

Error when Upload file to twitter = chunk method #253

vitqst opened this issue Nov 9, 2017 · 0 comments

Comments

@vitqst
Copy link

vitqst commented Nov 9, 2017

$file = fopen($this->filePath, "r");
while (! feof($file)) {
            $chunk = fread($file, 1048576);

            $dataRequest = [
                "command" => "APPEND",
                "media_id" => $this->mediaId,
                "media_data" => base64_encode($chunk),
                "segment_index" => $segmentId,
            ];

            $this->twitter->request(self::API_MEDIA_ENDPOINT_URL, "POST", $dataRequest);

            if (
                $this->twitter->getHttpStatusCode() < 200 ||
                $this->twitter->getHttpStatusCode() > 299 ||
                $this->twitter->getHttpStatusCode() === 204 // No Content
            ) {
                $this->print("status_code : " . $this->twitter->getHttpStatusCode());
                $this->print($this->twitter->getPostfields());
                exit;
            }

            $segmentId++;
            $bytesSent = ftell($file);
            printf("\n%s of %s bytes uploaded\n", $bytesSent, $this->fileSize);
}    

this is my code, i think request don't have "multipart/form-data"

@J7mbo J7mbo closed this as completed Jan 15, 2025
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants