Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when Upload file to twitter = chunk method #253

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

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant