当前位置: 首页>>代码示例>>PHP>>正文


PHP Rest::postRaw方法代码示例

本文整理汇总了PHP中Rest::postRaw方法的典型用法代码示例。如果您正苦于以下问题:PHP Rest::postRaw方法的具体用法?PHP Rest::postRaw怎么用?PHP Rest::postRaw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rest的用法示例。


在下文中一共展示了Rest::postRaw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _transfer


//.........这里部分代码省略.........
{$payload}

EOD;
                                $stats['videos']++;
                                $syncPlaylist = MigratedDataModel::create();
                                $syncPlaylist->source_id = $source['username']['id'];
                                $syncPlaylist->destination_id = $destination['username']['id'];
                                $syncPlaylist->task_id = 0;
                                $syncPlaylist->sync_task_id = $syncTaskId;
                                $syncPlaylist->table = VideosModel::$schema['table'];
                                $syncPlaylist->table_id = $video['id'];
                                $syncPlaylist->kind = static::$kind['video'];
                                $syncPlaylist->identifier = $video['video_link'];
                                $syncPlaylist->name = $video['title'];
                                $syncPlaylist->created = date(DATE_TIME);
                                $syncPlaylist->status = MigratedDataModel::STATUS_ACTIVE;
                                $syncPlaylist->save();
                            }
                        }
                    }
                }
            }
        }
        // Add subscriptions
        if ($subscriptions) {
            foreach ($subscriptions as $subscription) {
                // Whitelisting used for share feature
                $whiteListed = true;
                if ($whitelist) {
                    if (isset($whitelist['subscriptions']) && $whitelist['subscriptions']) {
                        if (!in_array($subscription['channel_link'], $whitelist['subscriptions'])) {
                            $whiteListed = false;
                        }
                    }
                }
                if (!in_array($subscription['channel_link'], $syncedSubscriptions) && $whiteListed || $ignoreUpdate) {
                    if ($counter == 998) {
                        $batch = md5(time());
                        $counter = 0;
                    }
                    $counter++;
                    $payload = array();
                    $payload['snippet']['resourceId']['kind'] = static::$kind['channel'];
                    $payload['snippet']['resourceId']['channelId'] = $subscription['channel_link'];
                    $payload = json_encode($payload);
                    $batches[$batch][$subscription['channel_link']][] = <<<EOD

POST https://www.googleapis.com/youtube/v3/subscriptions?part=snippet
Content-Type:  application/json
Authorization: Bearer {$destination['credentials']['access_token']}

{$payload}

EOD;
                    $stats['subscriptions']++;
                    $syncPlaylist = MigratedDataModel::create();
                    $syncPlaylist->source_id = $source['username']['id'];
                    $syncPlaylist->destination_id = $destination['username']['id'];
                    $syncPlaylist->task_id = 0;
                    $syncPlaylist->sync_task_id = $syncTaskId;
                    $syncPlaylist->table = SubscriptionsModel::$schema['table'];
                    $syncPlaylist->table_id = $subscription['id'];
                    $syncPlaylist->kind = static::$kind['subscription'];
                    $syncPlaylist->identifier = $subscription['channel_link'];
                    $syncPlaylist->name = $subscription['title'];
                    $syncPlaylist->created = date(DATE_TIME);
                    $syncPlaylist->status = MigratedDataModel::STATUS_ACTIVE;
                    $syncPlaylist->save();
                }
            }
        }
        if ($batches) {
            foreach ($batches as $key => $batch) {
                for ($i = 0; $i < 500; $i++) {
                    $body = '';
                    $y = md5($i);
                    foreach ($batch as $k => $set) {
                        $keys = $k . '-' . $i;
                        if (isset($set[$i])) {
                            $body .= <<<EOD
--{$y}
Content-Type: application/http
Content-Transfer-Encoding: binary
MIME-Version: 1.0
Content-ID:{$keys}
{$set[$i]}

EOD;
                        }
                    }
                    if ($body) {
                        $body .= "--" . $y . "--";
                        $destination['boundary'] = $y;
                        $insert = \Rest::postRaw('https://www.googleapis.com/batch', $body, $destination);
                    }
                }
            }
        }
        return $stats;
    }
开发者ID:unDemian,项目名称:gcdc-migrate,代码行数:101,代码来源:Youtube.php


注:本文中的Rest::postRaw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。