0

I'm working on generation of Google Presentation (template with more than 50 slides) using PHP SDK, and recently when I use the method replaceAllShapeWithImage, it takes a long time to throw one of theses messages :

Error Message 1 :

{ "error": { "code": 500, "message": "Internal error encountered.", "errors": [ { "message": "Internal error encountered.", "domain": "global", "reason": "backendError" } ], "status": "INTERNAL" } }

Error Message 2:

{ "error": { "code": 503, "message": "The service is currently unavailable.", "errors": [ { "message": "The service is currently unavailable.", "domain": "global", "reason": "backendError" } ], "status": "UNAVAILABLE" } }

Here's some code to test:

function replaceAllShapeWithImageT(array &$requests,  $objectId,  $image_url, $replace_mothod ='CENTER_CROP')
{
        $requests[] = new Google_Service_Slides_Request(array(
              'replaceAllShapesWithImage' => array(
                'imageUrl' => $image_url,
                'imageReplaceMethod' => $replace_mothod,
                'containsText' => array(
                  'text' => $objectId,
                  'matchCase' => true
                )
            )
        ));
}


function testGenBatch($client)
{
    echo "\n STart";
    $slidesService = new Google_Service_Slides($client); 
    $presentationCopyId ='SLIDE_ID';
    $requests = [];
    replaceAllShapeWithImageT($requests, '{{destination_image}}', "https://picsum.photos/1400/800?image=1076");
    replaceAllShapeWithImageT($requests, '{{client_logo}}', "https://picsum.photos/400/200?image=1069");
    replaceAllShapeWithImageT($requests, '{{country_image}}', "https://picsum.photos/1400/800?image=1073");


    replaceAllShapeWithImageT($requests, '{{hotel_0_thumb}}', "https://picsum.photos/900/500");
    replaceAllShapeWithImageT($requests, '{{hotel_1_image_1}}', "https://picsum.photos/1400/800?image=1079");
    replaceAllShapeWithImageT($requests, '{{hotel_1_image_2}}', "https://picsum.photos/1400/800?image=1080");
    replaceAllShapeWithImageT($requests, '{{hotel_1_image_3}}', "https://picsum.photos/1400/800?image=1082");

    $batchUpdateRequest = new Google_Service_Slides_BatchUpdatePresentationRequest(array(
      'requests' => $requests
    ));
    try {
        echo "\n Launch BAtch Request\n";
        $response = $slidesService->presentations->batchUpdate($presentationCopyId, $batchUpdateRequest);
        // var_dump($response);
        echo "\n DOOOOOOOOOOOOOOOOOOOOOONE\n";
    } catch(\Exception $e) {
        echo "\nErrooor : ".$e->getMessage()."\n====================================================\n";
    }
}

Thank you

elhaj
  • 438
  • 5
  • 10
  • Can you add any details like code used? [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask), [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) Show the community what you have tried. – abielita Apr 13 '18 at 16:26
  • Are you running this code in Google Compute Platform? If so, where? Knowing that could help to identify the cause if this error. Also could you give the exact day when the errors started to appear? – A.Queue May 02 '18 at 12:59

0 Answers0