gpt4 book ai didi

php - 使用 php 从 Curl 更新 Mysql

转载 作者:太空宇宙 更新时间:2023-11-03 10:54:23 29 4
gpt4 key购买 nike

我有一个 php curl 脚本

$ch = curl_init();
$fp = fopen("cache/temp_file.txt", "w");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, "https://upload.wistia.com" );
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'progressCallback');
curl_setopt($ch, CURLOPT_BUFFERSIZE, (1024*1024*512));
curl_setopt($ch, CURLOPT_NOPROGRESS, FALSE);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$result = curl_exec($ch);
echo $result;
fwrite($fp, $result);
curl_close($ch);
fclose($fp);

返回一个字符串

 $result={"id":5966875,"name":"php3il8M4","type":"Video","created":"2014-02-18T10:00:57+00:00","updated":"2014-02-18T10:00:57+00:00","duration":10.29,"hashed_id":"772ecmi61h","description":"","progress":0.0,"status":"queued","thumbnail":{"url":"http://embed.wistia.com/deliveries/a351871a559000f83c39f3e84b33a491c5e5224a.jpg?image_crop_resized=100x60&video_still_time=5","width":100,"height":60}}

我只想将“名称”之后的值写入 mysql:“例如 php3il8M4

并更新我的 mysql 数据库,例如

 UPDATE $table SET code='$name' WHERE id=$id

我不确定执行此操作的最佳方法是什么。

最佳答案

你可以用作

$data = json_decode($result,true);
$name = $data["name"];

这里 $name 将包含名称,您可以在查询中使用它

关于php - 使用 php 从 Curl 更新 Mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21850333/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com