小编jay*_*rap的帖子

使用Youtube API V3和PHP将视频上传到Youtube

我正在尝试使用PHP将视频上传到Youtube.我正在使用Youtube API v3,我正在使用最新检出的Google API PHP客户端库源代码.
我使用
https://code.google.com/p/google-api-php-client/上提供的示例代码来执行身份验证.身份验证很顺利,但是当我尝试上传视频时,我得到Google_ServiceException的错误代码为500,消息为null.

我看了之前提到的以下问题: 使用php客户端库v3视频上传到youtube但是接受的答案没有描述如何指定要上传的文件数据.
我发现了另一个类似的问题使用Youtube API v3和PHP上传文件,其中在评论中提到categoryId是必需的,因此我尝试在片段中设置categoryId,但它仍然提供相同的异常.

我还提到了文档站点上的Python代码(https://developers.google.com/youtube/v3/docs/videos/insert),但我在客户端库中找不到函数next_chunk.但我试图在循环(在代码片段中提到)重试获取错误代码500,但在所有10次迭代中我得到相同的错误.

以下是我正在尝试的代码段:

$youTubeService = new Google_YoutubeService($client);
if ($client->getAccessToken()) {
    print "Successfully authenticated";
    $snippet = new Google_VideoSnippet();
    $snippet->setTitle = "My Demo title";
    $snippet->setDescription = "My Demo descrition";
    $snippet->setTags = array("tag1","tag2");
    $snippet->setCategoryId(23); // this was added later after refering to another question on stackoverflow

    $status = new Google_VideoStatus();
    $status->privacyStatus = "private";

    $video = new Google_Video();
    $video->setSnippet($snippet);
    $video->setStatus($status);

    $data = file_get_contents("video.mp4"); …
Run Code Online (Sandbox Code Playgroud)

php youtube-api google-api-php-client

21
推荐指数
1
解决办法
4万
查看次数

Spring Scheduler - 当存在循环依赖时,调度方法不会在事务中启动

我正在使用一个使用Spring 3,Hibernate和JPA的应用程序.我有两个课程如下:

@Component
class Manager {
    @Autowired
    Util util;
}
Run Code Online (Sandbox Code Playgroud)

@Component
class Util {
    @Autowired
    Manager manager;

    @Scheduled(fixedDelay = 1 * 60 * 1000)
    @Transactional(propagation = Propagation.REQUIRED)
    public void scheduledMethod(){
        // Need to update the database in a transaction
    }
}
Run Code Online (Sandbox Code Playgroud)

申请背景的相关部分如下:

    <context:component-scan base-package="packageName" />
    <tx:annotation-driven />
    <bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
       <property name="persistenceUnitName" value="defaultPU" />
       <property name="dataSource" ref="dataSource" />
    </bean>
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
       <property name="entityManagerFactory" ref="entityManagerFactory" />
    </bean>
    <task:annotation-driven executor="executor" scheduler="scheduler"/>
    <task:executor id="executor"
       pool-size="10"
       queue-capacity="10000"
       rejection-policy="CALLER_RUNS"/>
    <task:scheduler id="scheduler" pool-size="10"/>
Run Code Online (Sandbox Code Playgroud)

使用此配置,我得到以下异常 …

java spring spring-transactions spring-scheduled

6
推荐指数
1
解决办法
629
查看次数

还款管理的数据库模式设计

我们有一个用于跟踪贷款定期付款的网络应用程序,目前我们在 mysql 数据库中管理它,如下所示:

loan_payments 包含以下列的表格 [ id, customerId, installmentNo, installmentAmount, penalty, previousOutstanding, totalReceivable, amountReceived ]

receipts 包含以下列的表格 [ id, loan_payments.id (FK), paymentAmount, otherPaymentDetails]

代码流程如下:

  1. 在创建新贷款期间,会在该客户的表中输入nrInstallmentsloan_payments假设所有客户有固定的 10 期分期付款,将创建 10 行
  2. 对于第一行 ( installmentNo= 1 ),penaltypreviousOutstanding将设置为 0。
  3. 每当收到新付款时,当前分期付款 ( = 1)amountReceived中的金额就会增加,并在表中完成一个条目。*在任何给定时间只有一个当前分期付款*installmentNopayments
  4. 下一期 ( installmentNo= 2) 时,上一期的[ totalReceivable - amountReceived ]插入到下一期的 ( installmentNo= 2) 中previousOutstanding。所有以前的付款/分期付款都被冻结。并向客户发送提示,表明installmentAmountpenalty和 …

database-design

5
推荐指数
1
解决办法
6893
查看次数