dongpeng0127 2019-01-28 14:37
浏览 182

404当我使用php-client-forge autodesk api时连接到API(https://developer.api.autodesk.com/modelderivative/v2/designdata/job)时出错

i want to use the autodesk forge viewer api in my php application in order to view ifc files so i used the forge-php-client sdk.everything works fine but the translating job doesn't and i'm getting this error : [404] Error connecting to the API (https://developer.api.autodesk.com/modelderivative/v2/designdata/job here the code:

/step1

        Configuration::getDefaultConfiguration()
                ->setClientId('xxxxxxxxxxxxxxxxxxxxxx')
                ->setClientSecret('xxxxxxxxxxxxxxxxxx');

        $twoLeggedAuth = new TwoLeggedAuth();
        $twoLeggedAuth->setScopes( [ 'bucket:create' ] );    

        $twoLeggedAuth->fetchToken();

        $tokenInfo = [
           'accessToken' => $twoLeggedAuth->getAccessToken(),
           'expiry'           => time() + $twoLeggedAuth->getExpiresIn(),
        ];

        //step2

        $twoLeggedAuth->setScopes( [ 'bucket:create' ] );
        $twoLeggedAuth->fetchToken();

        $apiInstance = new BucketsApi( $twoLeggedAuth );

        $bucket_info = array(
        'bucket_key' => 'nebnibim5'.time(),  
        'policy_key' => 'transient' 
        );
        $post_buckets = new PostBucketsPayload( $bucket_info );


        $result = $apiInstance->createBucket( $post_buckets, null );





        $twoLeggedAuth = new TwoLeggedAuth();
        $twoLeggedAuth->setScopes( [ 'data:write' ] );

        $twoLeggedAuth->fetchToken();

        $apiInstance = new ObjectsApi( $twoLeggedAuth );
        $bucket_key = $bucket_info['bucket_key']; 

        $filename = 'C:\wamp\www
ebnibim\storage\app\bibliothequeObjets\user69\13111006_IFCR2_Geo_Openings_1.ifc '; 
        $body = $filename;
        $file = new SplFileObject( $body );
        $content_length = $file->getSize();   
        $object_name = $file->getFilename();  

        //try {
        $result2 = $apiInstance->uploadObject( $bucket_key, $object_name, $content_length, $body, null, null );



        //step4
        $urn = 'urn:adsk.objects:os.object:nebnibim51548575979/13111006_IFCR2_Geo_Openings_1.ifc';
        $base64Urn = rtrim( strtr( base64_encode( $urn ), '+/', '-_' ), '=' );

        $twoLeggedAuth->setScopes( [ 'data:read', 'data:write' ] );
        $twoLeggedAuth->fetchToken();

        $apiInstance2 = new DerivativesApi( $twoLeggedAuth );

        $jobInput = array(
        'urn' => 'dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6bmVibmliaW01MTU0ODU3NTk3OS8xMzExMTAwNl9JRkNSMl9HZW9fT3BlbmluZ3NfMS5pZmM'
        );

        $jobPayloadInput = new JobPayloadInput( $jobInput );

        $jobOutputItem = array(
        'type' => 'svf',
        'views' => array( '2d', '3d' )
        );

        $jobPayloadItem = new JobPayloadItem( $jobOutputItem );

        $jobOutput = [
        'formats' => array( $jobPayloadItem )        

        ];

        $jobPayloadOutput = new JobPayloadOutput( $jobOutput );


        $job = new JobPayload();

        $job->setInput( $jobPayloadInput );
        $job->setOutput( $jobPayloadOutput );
        $x_ads_force = false;

        $resultat= $apiInstance2->translate( $job,$x_ads_force );
  • 写回答

1条回答 默认 最新

  • duanjianxiu9400 2019-01-29 15:01
    关注

    Looks like you are still uploading to a bucket named after system time, only to call job on a hard coded urn pointing an object that’s uploaded to another bucket earlier - this would always result in a 404 error as the urn is incorrect.

    Follow the code sample and docs here to fetch a list of the contents of an existing bucket, verify the objects really exist at the time of query in your bucket, take the objectId returned that’s guaranteed to be current and correct, and go from there.

    You will need to upload the files again after 24 hours as the bucket you created is transient. See here for more on this - and that should be the reason for the error we are seeing now.

    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?