Giter VIP home page Giter VIP logo

Comments (3)

tioffs avatar tioffs commented on July 21, 2024

Call this method as many times as you need to upload photos

$photo_id = round(microtime(true) * 1000);
$file_temp = __DIR__ . '/' . $this->uuid4();
list($width, $height, $image_type) = getimagesize(realpath($photo));
$srcImage = ImageCreateFromJPEG($photo);
$resImage = ImageCreateTrueColor($width, $height);
ImageCopyResampled($resImage, $srcImage, 0, 0, 0, 0, $width, $height, $width, $height);
ImageJPEG($srcImage, $file_temp, 100);
ImageDestroy($srcImage);
$response = Request::post($this->web . 'rupload_igphoto/fb_uploader_' . $photo_id)
->addHead('content-type', 'image/jpg')
->addHead('x-entity-name', 'fb_uploader_' . $photo_id)
->addHead('offset', 0)
->addHead('user-agent', 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_4_1 like Mac OS X; ru-RU) AppleWebKit/537.36 (KHTML, like Gecko) Version/11.4.1 Mobile/15G77 Safari/537.36 Puffin/5.2.2IP')
->addHead('x-entity-length', filesize($file_temp))
->addHead('x-instagram-rupload-params', '{"media_type":1,"upload_id":"' . $photo_id . '","upload_media_height":' . $height . ',"upload_media_width":' . $width . '}')
->addFile($file_temp)
->json(true);
unlink($file_temp);
if (!isset($response['upload_id'], $response['status']) && $response['status'] != 'ok') {
throw new Exception("Error upload file: " . \json_encode($response));
}

Here you need to pass an array of responses received earlier
->addParam('upload_id', $response['upload_id'])

@example
-> addParam( 'upload_id' , [$response1[ 'upload_id' ],$response2[ 'upload_id' ],$response3[ 'upload_id' ]])

from instalite.

pbadun avatar pbadun commented on July 21, 2024

Not work.

Send:
Array
(
[0] => 1622750604563
[1] => 1622750606010
[2] => 1622750607029
)

Result:

Uncaught InstaLite\Exception: Error save post: {"message":"Missing info.","status":"fail"}

from instalite.

pbadun avatar pbadun commented on July 21, 2024

$upload_id = [];
foreach ($ph as $photo) {
if (!file_exists($photo)) {
throw new Exception("File [$photo] not found");
}
$photo_id = round(microtime(true) * 1000);
$file_temp = DIR . '/' . $this->uuid4();
list($width, $height, $image_type) = getimagesize(realpath($photo));
$srcImage = ImageCreateFromJPEG($photo);
$resImage = ImageCreateTrueColor($width, $height);
ImageCopyResampled($resImage, $srcImage, 0, 0, 0, 0, $width, $height, $width, $height);
ImageJPEG($srcImage, $file_temp, 100);
ImageDestroy($srcImage);

        $response = Request::post($this->web . 'rupload_igphoto/fb_uploader_' . $photo_id)
            ->addHead('content-type', 'image/jpg')
            ->addHead('x-entity-name', 'fb_uploader_' . $photo_id)
            ->addHead('offset', 0)
            ->addHead('user-agent', 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_4_1 like Mac OS X; ru-RU) AppleWebKit/537.36 (KHTML, like Gecko)  Version/11.4.1 Mobile/15G77 Safari/537.36 Puffin/5.2.2IP')
            ->addHead('x-entity-length', filesize($file_temp))
            ->addHead('x-instagram-rupload-params', '{"media_type":1,"upload_id":"' . $photo_id . '","upload_media_height":' . $height . ',"upload_media_width":' . $width . '}')
            ->addFile($file_temp)
            ->json(true);
        unlink($file_temp);
        if (!isset($response['upload_id'], $response['status']) && $response['status'] != 'ok') {
            throw new Exception("Error upload file: " . \json_encode($response));
        }
        $this->__log('upload file success: ' . \json_encode($response));
        $upload_id[] = $response['upload_id'];
    }
    print_r($upload_id);


    $response = Request::post($this->web . 'create/configure/')
        ->addHead('content-type', 'application/x-www-form-urlencoded')
        ->addHead('user-agent', 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_4_1 like Mac OS X; ru-RU) AppleWebKit/537.36 (KHTML, like Gecko)  Version/11.4.1 Mobile/15G77 Safari/537.36 Puffin/5.2.2IP')
        ->addParam('upload_id', $upload_id)
        ->addParam('caption', $message)
        ->addParam('usertags', '')
        ->addParam('custom_accessibility_caption', '')
        ->addParam('retry_timeout', '')
        ->json(true);

    print_r($response);

from instalite.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.