我正在实施谷歌驱动器API.
我已经推荐了这个谷歌文档https://developers.google.com/api-client-library/php/auth/web-app#example.
这是我的index.php
<?php
require_once __DIR__ . '/vendor/autoload.php';
session_start();
$client = new Google_Client();
$client->setAuthConfigFile('client_secret.json');
$client->addScope(Google_Service_Drive::DRIVE_METADATA_READONLY);
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
$client->setAccessToken($_SESSION['access_token']);
$drive_service = new Google_Service_Drive($client);
$files_list = $drive_service->files->listFiles(array())->getItems();
echo json_encode($files_list);
} else {
$redirect_uri = 'http://127.0.0.1/googleApiQuickstart/oauth2callback.php';
header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}
Run Code Online (Sandbox Code Playgroud)
还有我的oauth2callback.php
<?php
require_once __DIR__ . '/vendor/autoload.php';
session_start();
$client = new Google_Client();
$client->setAuthConfigFile('client_secret.json');
$client->setRedirectUri('http://127.0.0.1/googleApiQuickstart/oauth2callback.php');
$client->addScope(Google_Service_Drive::DRIVE_METADATA_READONLY);
if (!isset($_GET['code'])) {
$auth_url = $client->createAuthUrl();
header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
} else {
$client->authenticate($_GET['code']);
$_SESSION['access_token'] = $client->getAccessToken();
$redirect_uri = 'http://127.0.0.1/googleApiQuickstart';
header('Location: …Run Code Online (Sandbox Code Playgroud) 我在foreach中返回数组的第一个键时遇到问题.我可以返回$ key但我不知道只返回第一个$ key.
<td>
<div align="center">
<span class="formlist">
<select id="plant" name="plant[]" class="form-control" multiple="multiple">
<?php
$query_plant = "SELECT * FROM plant WHERE plant_enable=1 ORDER BY plant_name";
$rs_plant = DB_Query($query_plant);
while ($row_plant = DB_FetchRow($rs_plant)) {
$plant.='<option name='.$row_plant["plant_shortname"].' value='.$row_plant["plant_id"].'>' .$row_plant["plant_name"].' ['.$row_plant["plant_id"].']</option>';
}
mysql_free_result($rs_plant);
echo $plant;
?>
</select>
</span>
</div>
</td>
if(isset($_POST['plant'])) {
$checkbox1 = $_POST['plant'];
$chk="";
$stf_sql = "SELECT * FROM test_plant WHERE staff_id = '".$STAFF_ID."'";
$stf_res = DB_Query($stf_sql);
if(DB_RowsReturned($stf_res) > 0) {
$del_sql = "DELETE FROM test_plant WHERE staff_id = '".$STAFF_ID."'";
$del_res …Run Code Online (Sandbox Code Playgroud) 我在 ZendFramework2 上并使用doctrine2。
我想查找从今天的日期时间到下一个或过去 30 天与交易相关的所有记录。
这是我的学说查询和代码,
$emailRepo = $em->getRepository('App\Entity\Email')->findBy(['deal' => $deal]);
foreach ($emailRepo as $email) {
$sendAt = $email->getSendAt();
}
Run Code Online (Sandbox Code Playgroud)
我在 sendAt 变量中有DateTime对象,
从一些参考文献中我找到了这个strtotime函数。
$data = date('Y-m-d h:i:s', strtotime("+30 days"));
$data = date('Y-m-d h:i:s', strtotime("-30 days"));
Run Code Online (Sandbox Code Playgroud)
但它对我不起作用。
正确的写法是什么?
我试图将数组值设置为名为输入字段 attachments[]
我有数组存储在js变量中 attachArray
我试过的是
$('[name="attachments"]').attr('value', attachArray);
Run Code Online (Sandbox Code Playgroud)
要么
$('[name="attachments"]').val(attachArray);
Run Code Online (Sandbox Code Playgroud)
但是attachments像这样在控制器中变空了
array(1) { ["attachments"]=> array(1) { [0]=> string(0) "" } }
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
编辑
<div class="col-md-4">
<div class="form-group ticket-align">
<label>Attachment</label>
<label class="btn btn-primary" data-toggle="modal" data-target="#t-attachment-modal">
Browse…
<input type="hidden" name="attachments[]">
</label>
<span id="fileList"></span>
<span class="error" id="error-atachments" style='display: none;'></span>
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 我有几个网址,例如
https://example.com/
http://example.com/
我只想要“example.com”作为字符串
我想删除
https:// 和 http://
所以我采取了这样的阵列,
$removeChar = ["https://", "http://", "/"];
Run Code Online (Sandbox Code Playgroud)
删除这些的正确方法是什么?
我正在使用这个wkhtmltopdf 0.12.3 (with patched qt)版本的 wkhtmltopdf。使用蒙特塞拉特字体系列。
HTML是这样的,
<strong>
This Agreement for home staging and rental of furniture and accessories
</strong>
(“Agreement”) is entered this
Run Code Online (Sandbox Code Playgroud)
其中输出为,
同意家居装饰和家具及配件的租赁(???同意??)
和,
<u>Services</u>
Subject to the terms and conditions of this </span>
Run Code Online (Sandbox Code Playgroud)
其中输出为,
 服务 受本条款和条件的约束
为什么这些Â介于两者之间?
我试图替换这样的引号和空格,
$formData = str_replace(' ', ' ', $formData);
$formData = str_replace('"', '"', $formData);
$formData = str_replace('“', '"', $formData);
$formData = str_replace('”', '"', $formData);
Run Code Online (Sandbox Code Playgroud)
但没有帮助。难道我做错了什么?已搜索,但找不到解决方案。
我正在尝试通过单击按钮上传文件。
我按照像,这么多的教程/问题, 上载一个按钮的所有文件,在laravel 5.4 Dropzone.js POST请求。但没有获得成功。
这是我的视图文件代码,
<form action="{{ url('admin/candidate/file-upload') }}" method="post" class="dropzone" id="my-dropzone">
{{ csrf_field() }}
<div class="dz-message">
<h3>Drop images here or click to upload.</h3>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
这是我的 JS 文件代码(在文档就绪块中),
//DropZone - Drag and drop file upload
Dropzone.options.myDropzone = {
// Prevents Dropzone from uploading dropped files immediately
autoProcessQueue: false,
init: function () {
var submitButton = document.querySelector("#submit-all")
myDropzone = this; // closure
submitButton.addEventListener("click", function () {
myDropzone.processQueue(); // Tell Dropzone to process all queued files. …Run Code Online (Sandbox Code Playgroud) 我已经提到了下面列出的这些问题,但没有帮助我。
我想从具有特定值的对象中获取计数。例如,我有这个数组列表,
var testData = [
{
"issue_type": "Warning",
"created_date": "2019-05-13T13:43:16.437Z",
},
{
"issue_type": "Warning",
"created_date": "2019-05-13T13:45:16.330Z",
},
{
"issue_type": "Alert",
"created_date": "2019-05-13T13:43:16.437Z",
},
{
"issue_type": "Alert",
"created_date": "2019-05-13T13:45:16.330Z",
}
]
Run Code Online (Sandbox Code Playgroud)
我想计算有多少带有键的对象"issue_type"="Warning"。
我试过这个循环,但这不是我要找的,
var counts = {};
for (var i = 0; i < arr.length; i++) {
var num = arr[i];
counts[num] = counts[num] ? counts[num] + 1 : 1;
}
console.log(count['issue_type']);
Run Code Online (Sandbox Code Playgroud)
请给我建议出路。
php ×6
arrays ×4
javascript ×2
jquery ×2
datetime ×1
doctrine-orm ×1
dropzone.js ×1
google-api ×1
key ×1
laravel-5.4 ×1
post ×1
preg-match ×1
wkhtmltopdf ×1