<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://purl.org/rss/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel rdf:about="https://dwt.life/feed/rss/category/code/">
<title>dwt&#039;s life - Coding</title>
<link>https://dwt.life/category/code/</link>
<description></description>
<items>
<rdf:Seq>
<rdf:li resource="https://dwt.life/archives/342/"/>
<rdf:li resource="https://dwt.life/archives/333/"/>
<rdf:li resource="https://dwt.life/archives/327/"/>
<rdf:li resource="https://dwt.life/archives/323/"/>
<rdf:li resource="https://dwt.life/archives/321/"/>
<rdf:li resource="https://dwt.life/archives/320/"/>
<rdf:li resource="https://dwt.life/archives/314/"/>
<rdf:li resource="https://dwt.life/archives/311/"/>
<rdf:li resource="https://dwt.life/archives/308/"/>
<rdf:li resource="https://dwt.life/archives/271/"/>
</rdf:Seq>
</items>
</channel>
<item rdf:about="https://dwt.life/archives/342/">
<title>gomobile 编译</title>
<link>https://dwt.life/archives/342/</link>
<dc:date>2024-07-27T18:38:53+08:00</dc:date>
<description>gomobile bind -target=android golang.org/x/mobile/example/bind/hello
gomobile bind -target=android ./engine</description>
</item>
<item rdf:about="https://dwt.life/archives/333/">
<title>【转载】MySql 外键约束 之CASCADE、SET NULL、RESTRICT、NO ACTION分析和作用</title>
<link>https://dwt.life/archives/333/</link>
<dc:date>2023-06-20T19:30:49+08:00</dc:date>
<description>https://www.cnblogs.com/yzuzhang/p/5174720.htmlMySQL有两种常用的引擎类型：MyISAM和InnoDB。目前只有InnoDB引擎类型支持外键约束。InnoDB中外键约束定义的语法如下：ALTER TABLE tbl_name
    ADD [CONSTRAINT [symbol]] FOREIGN KEY
    [index_name] (index_col_name, ...)
    REFERENCES tbl_name (index_col_name,...)
    [ON DELETE reference_option]
    [ON UPDATE reference_option]例如：ALTER TABLE `user_resource` CONSTRAINT `FKEEAF1E02D82D57F9` FOREIGN KEY (`user_Id`) REFERENCES `sys_user` (`Id`)InnoDB也支持使用ALTER TABLE来删除外键：ALTER TABLE user_resource DROP FOREIGN KEY FKEEAF1E02D82D57F9;CASCADE在父表上update/delete记录时，同步update/delete掉子表的匹配记录 SET NULL在父表上update/delete记录时，将子表上匹配记录的列设为null (要注意子表的外键列不能为not null)  NO ACTION如果子表中有匹配的记录,则不允许对父表对应候选键进行update/delete操作  RESTRICT同no action, 都是立即检查外键约束SET NULL父表有变更时,子表将外键列设置成一个默认的值 但Innodb不能识别NULL、RESTRICT、NO ACTION删除：从表记录不存在时，主表才可以删除。删除从表，主表不变更新：从表记录不存在时，主表才可以更新。更新从表，主表不变CASCADE删除：删除主表时自动删除从表。删除从表，主表不变更新：更新主表时自动更新从表。更新从表，主表不变SET NULL删除：删除主表时自动更新从表值为NULL。删除从表，主表不变更新：更新主表时自动更新从表值为NULL。更新从表，主表不变外键约束属性： RESTRICT | CASCADE | SET NULL | NO ACTION  外键的使用需要满足下列的条件：两张表必须都是InnoDB表，并且它们没有临时表。建立外键关系的对应列必须具有相似的InnoDB内部数据类型。建立外键关系的对应列必须建立了索引。假如显式的给出了CONSTRAINT symbol，那symbol在数据库中必须是唯一的。假如没有显式的给出，InnoDB会自动的创建。如果子表试图创建一个在父表中不存在的外键值，InnoDB会拒绝任何INSERT或UPDATE操作。如果父表试图UPDATE或者DELETE任何子 表中存在或匹配的外键值，最终动作取决于外键约束定义中的ON UPDATE和ON DELETE选项。InnoDB支持5种不同的动作，如果没有指定ON DELETE或者ON UPDATE，默认的动作为RESTRICT:CASCADE: 从父表中删除或更新对应的行，同时自动的删除或更新自表中匹配的行。ON DELETE CANSCADE和ON UPDATE CANSCADE都被InnoDB所支持。SET NULL: 从父表中删除或更新对应的行，同时将子表中的外键列设为空。注意，这些在外键列没有被设为NOT NULL时才有效。ON DELETE SET NULL和ON UPDATE SET SET NULL都被InnoDB所支持。NO ACTION: InnoDB拒绝删除或者更新父表。RESTRICT: 拒绝删除或者更新父表。指定RESTRICT（或者NO ACTION）和忽略ON DELETE或者ON UPDATE选项的效果是一样的。SET DEFAULT: InnoDB目前不支持。外键约束使用最多的两种情况无外乎：1）父表更新时子表也更新，父表删除时如果子表有匹配的项，删除失败；2）父表更新时子表也更新，父表删除时子表匹配的项也删除。前一种情况，在外键定义中，我们使用ON UPDATE CASCADE ON DELETE RESTRICT；后一种情况，可以使用ON UPDATE CASCADE ON DELETE CASCADE。当执行外键检查之时，InnoDB对它照看着的子或父记录设置共享的行级锁。InnoDB立即检查外键约束，检查不对事务提交延迟。要使得对有外键关系的表重新载入转储文件变得更容易，mysqldump自动在转储输出中包括一个语句设置FOREIGN_KEY_CHECKS为0。这避免在转储被重新装载之时，与不得不被以特别顺序重新装载的表相关的问题。也可以手动设置这个变量：mysql&gt; SET FOREIGN_KEY_CHECKS = 0;

mysql&gt; SOURCE dump_file_name;

mysql&gt; SET FOREIGN_KEY_CHECKS = 1;　　如果转储文件包含对外键是不正确顺序的表，这就以任何顺序导入该表。这样也加快导入操作。设置FOREIGN_KEY_CHECKS为0，对于在LOAD DATA和ALTER TABLE操作中忽略外键限制也是非常有用的。InnoDB不允许你删除一个被FOREIGN KEY表约束引用的表，除非你做设置SET FOREIGN_KEY_CHECKS=0。当你移除一个表的时候，在它的创建语句里定义的约束也被移除。　　如果你重新创建一个被移除的表，它必须有一个遵从于也引用它的外键约束的定义。它必须有正确的列名和类型，并且如前所述，它必须对被引用的键有索引。如果这些不被满足，MySQL返回错误号1005 并在错误信息字符串中指向errno 150。</description>
</item>
<item rdf:about="https://dwt.life/archives/327/">
<title>thinkphp6 消息队列</title>
<link>https://dwt.life/archives/327/</link>
<dc:date>2023-04-09T21:19:32+08:00</dc:date>
<description>安装composer require topthink/think-queue配置配置文件位于 config/queue.php使用redis作为消息队列&lt;?php 
return [
    &#039;default&#039;     =&gt; &#039;redis&#039;,
    &#039;connections&#039; =&gt; [
        &#039;sync&#039;     =&gt; [
            &#039;type&#039; =&gt; &#039;sync&#039;,
        ],
        &#039;database&#039; =&gt; [
            &#039;type&#039;       =&gt; &#039;database&#039;,
            &#039;queue&#039;      =&gt; &#039;default&#039;,
            &#039;table&#039;      =&gt; &#039;jobs&#039;,
            &#039;connection&#039; =&gt; null,
        ],
        &#039;redis&#039;    =&gt; [
            &#039;type&#039;       =&gt; &#039;redis&#039;,
            &#039;queue&#039;      =&gt; &#039;default&#039;,//默认队列名称
            &#039;host&#039;       =&gt; &#039;127.0.0.1&#039;,//Redis主机IP地址
            &#039;port&#039;       =&gt; 6379,//Redis端口
            &#039;password&#039;   =&gt; &#039;&#039;,//Redis密码
            &#039;select&#039;     =&gt; 1,//Redis数据库
            &#039;timeout&#039;    =&gt; 0,//Redis连接超时时间
            &#039;persistent&#039; =&gt; false,//是否长连接
        ],
    ],
    &#039;failed&#039;      =&gt; [
        &#039;type&#039;  =&gt; &#039;none&#039;,
        &#039;table&#039; =&gt; &#039;failed_jobs&#039;,
    ],
];创建消费类在app目录下创建目录job，创建类文件&lt;?php

namespace app\job;

use think\facade\Log;
use think\queue\Job;

class Test
{
    public function fire(Job $job, $data)
    {
        // 处理业务逻辑返回为true表示消费成功，则删除队列
        if($this-&gt;test($job-&gt;attempts())){
            // 删除队列
            $job-&gt;delete();
        }else{
            // 判断执行失败次数，到达设置值后删除消息队列
            if ($job-&gt;attempts() &gt;= 10) {
                Log::channel(&#039;qxsp&#039;)-&gt;info(&#039;到达规定次数删除了&#039;);
                // 删除队列
                $job-&gt;delete();
            }else{
                Log::channel(&#039;qxsp&#039;)-&gt;info(&#039;继续执行&#039;);
                // 重庆消息队列，重要：如果没有这样设置，默认的是1失败后1分钟执行一次，这样设置的话达到失败后隔多久执行下一次。官方的坑研究了好久。
                $job-&gt;release(120);
            }

        }
    }

    // 处理业务逻辑
    public function test($data)
    {
        Log::channel(&#039;qxsp&#039;)-&gt;info($data);
        return false;
    }
}创建任务类Queue::push($job, $data = '', $queue = null) 和Queue::later($delay, $job, $data = '', $queue = null) 两个方法，前者是立即执行，后者是在$delay秒后执行$job 是任务名命名空间是app\job的，比如上面的例子一,写Job1类名即可其他的需要些完整的类名，比如上面的例子二，需要写完整的类名app\lib\job\Job2如果一个任务类里有多个小任务的话，如上面的例子二，需要用@+方法名app\lib\job\Job2@task1、app\lib\job\Job2@task2$data 是你要传到任务里的参数$queue 队列名，指定这个任务是在哪个队列上执行，同下面监控队列的时候指定的队列名,可不填以下为上面消费类例子public function index()
{
    Queue::push(&#039;Test&#039;, date(&quot;h:i:sa&quot;), &#039;wu&#039;);
}监听任务并执行在根目录下执行使用该语句：修改消费类代码可以实时更新无需重启php think queue:listen使用该语句：修改消费类代码不会实时更新，需要重启才能生效php think queue:workhttps://www.kancloud.cn/w13244855188/think-queue-wu</description>
</item>
<item rdf:about="https://dwt.life/archives/323/">
<title>哪吒面板css</title>
<link>https://dwt.life/archives/323/</link>
<dc:date>2023-03-26T00:56:01+08:00</dc:date>
<description>&lt;style&gt;
/* 屏幕适配 */
@media only screen and (min-width: 1200px) {
    .ui.container {
    width: 80% !important;
}
}

@media only screen and (max-width: 767px) {
    .ui.card&gt;.content&gt;.header:not(.ui), .ui.cards&gt;.card&gt;.content&gt;.header:not(.ui) {
        margin-top: 0.4em !important;
    }
}

/* 整体图标 */
i.icon {
    color: #000;
    width: 1.2em !important;
}

/* 背景图片 */
body {
    content: &quot; &quot; !important;
    background: fixed !important;
    z-index: -1 !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    background-position: top !important;
    background-repeat: no-repeat !important;
    background-size: cover !important;
    background-image: url(https://p1.meituan.net/csc/1c9e91f33e74dc97fe3aababccb066bc1644625.png) !important;
    font-family: Arial,Helvetica,sans-serif !important;
}

/* 导航栏 */
.ui.large.menu {
    border: 0 !important;
    border-radius: 0px !important;
    background-color: rgba(255, 255, 255, 55%) !important;
}

/* 首页按钮 */
.ui.menu .active.item {
    background-color: transparent !important;
}

/* 导航栏下拉框 */
.ui.dropdown .menu {
    border: 0 !important;
    border-radius: 0 !important;
    background-color: rgba(255, 255, 255, 80%) !important;
}

/* 登陆按钮 */
.nezha-primary-btn {
    background-color: transparent !important;
    color: #000 !important;
}

/* 大卡片 */
#app .ui.fluid.accordion {
    background-color: #fbfbfb26 !important;
    border-radius: 0.4rem !important;
}

/* 小卡片 */
.ui.four.cards&gt;.card {
    border-radius: 0.6rem !important;
    background-color: #fafafaa3 !important;
}

.status.cards .wide.column {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    height: 3.3rem !important;
}

.status.cards .three.wide.column {
    padding-right: 0rem !important;
}

.status.cards .wide.column:nth-child(1) {
    margin-top: 2rem !important;
}

.status.cards .wide.column:nth-child(2) {
    margin-top: 2rem !important;
}

.status.cards .description {
    padding-bottom: 0 !important;
}

/* 小鸡名 */
.status.cards .flag {
    margin-right: 0.5rem !important;
}

/* 弹出卡片图标 */
.status.cards .header &gt; .info.icon {
    margin-right: 0 !important;
}

.nezha-secondary-font {
    color: #21ba45 !important;
}

v

/* 上传下载 */
.status.cards .outline.icon {
    margin-right: 1px !important;
}

i.arrow.alternate.circle.down.outline.icon {
    color: #21ba45 !important;
}

i.arrow.alternate.circle.up.outline.icon {
    color: red !important;
}

/* 弹出卡片小箭头 */
.ui.right.center.popup {
    margin: -3px 0 0 0.914286em !important;
    -webkit-transform-origin: left 50% !important;
    transform-origin: left 50% !important;
}

.ui.bottom.left.popup {
    margin-left: 1px !important;
    margin-top: 3px !important;
}

.ui.top.left.popup {
    margin-left: 0 !important;
    margin-bottom: 10px !important;
}

.ui.top.right.popup {
    margin-right: 0 !important;
    margin-bottom: 8px !important;
}

.ui.left.center.popup {
    margin: -3px .91428571em 0 0 !important;
    -webkit-transform-origin: right 50% !important;
    transform-origin: right 50% !important;
}

.ui.right.center.popup:before,
.ui.left.center.popup:before {
    border: 0px solid #fafafaeb !important;
    background: #fafafaeb !important;
}

.ui.top.popup:before {
    border-color: #fafafaeb transparent transparent !important;
}

.ui.popup:before {
    border-color: #fafafaeb transparent transparent !important;
}

.ui.bottom.left.popup:before {
    border-radius: 0 !important;
    border: 1px solid transparent !important;
    border-color: #fafafaeb transparent transparent !important;
    background: #fafafaeb !important;
    -webkit-box-shadow: 0px 0px 0 0 #fafafaeb !important;
    box-shadow: 0px 0px 0 0 #fafafaeb !important;
    -webkit-tap-highlight-color: rgba(0,0,0,0) !important;
}
.ui.bottom.right.popup:before {
    border-radius: 0 !important;
    border: 1px solid transparent !important;
    border-color: #fafafaeb transparent transparent !important;
    background: #fafafaeb !important
    -webkit-box-shadow: 0px 0px 0 0 #fafafaeb !important;
    box-shadow: 0px 0px 0 0 #fafafaeb !important;
    -webkit-tap-highlight-color: rgba(0,0,0,0) !important;
}

.ui.top.left.popup:before {
    border-radius: 0 !important;
    border: 1px solid transparent !important;
    border-color: #fafafaeb transparent transparent !important;
    background: #fafafaeb !important;
    -webkit-box-shadow: 0px 0px 0 0 #fafafaeb !important;
    box-shadow: 0px 0px 0 0 #fafafaeb !important;
    -webkit-tap-highlight-color: rgba(0,0,0,0) !important;
}

.ui.top.right.popup:before {
    border-radius: 0 !important;
    border: 1px solid transparent !important;
    border-color: #fafafaeb transparent transparent !important;
    background: #fafafaeb !important;
    -webkit-box-shadow: 0px 0px 0 0 #fafafaeb !important;
    box-shadow: 0px 0px 0 0 #fafafaeb !important;
    -webkit-tap-highlight-color: rgba(0,0,0,0) !important;
}

.ui.left.center.popup:before {
    border-radius: 0 !important;
    border: 1px solid transparent !important;
    border-color: #fafafaeb transparent transparent !important;
    background: #fafafaeb !important;
    -webkit-box-shadow: 0px 0px 0 0 #fafafaeb !important;
    box-shadow: 0px 0px 0 0 #fafafaeb !important;
    -webkit-tap-highlight-color: rgba(0,0,0,0) !important;
}

/* 弹出卡片 */
.status.cards .ui.content.popup {
    min-width: 20rem !important;
    line-height: 2rem !important;
    border-radius: 5px !important;
    border: 1px solid transparent !important;
    background-color: #fafafaeb !important;
    font-family: Arial,Helvetica,sans-serif !important;
}

.ui.content {
    margin: 0 !important;
    padding: 1em !important;
}

/* 服务页 */
.ui.table {
    background: RGB(225,225,225,0.6) !important;
}

.ui.table thead th {
    background: transparent !important;
}

/* 服务页进度条 */

/* 版权 */
.ui.inverted.segment, .ui.primary.inverted.segment {
    color: #000 !important;
    font-weight: bold !important;
    background-color: #fafafaa3 !important;
}
/* 进度条 */
.ui.progress {
    border-radius: 50rem !important;
}
.ui.progress .bar {
    min-width: 1.8em !important;
    border-radius: 15px !important;
    line-height: 1.65em !important;
    color:black
}
.ui.fine.progress&gt; .bar {
    background-color: #ba45ac !important;
}
.ui.progress&gt; .bar {
    background-color: #000 !important;
}

.ui.progress.fine .bar {
    background-image: linear-gradient(120deg, #d4fc79 0%, #96e6a1 100%);!important;
}

.ui.progress.warning .bar {
    background-image: linear-gradient(to right, #fa709a 0%, #fee140 100%); !important;
}

.ui.progress.error .bar {
    background-image: linear-gradient(to top, #ff0844 0%, #ffb199 100%);important;
}

.ui.progress.offline .bar {
    background-image: linear-gradient(to top, #e6e9f0 0%, #eef1f5 100%); !important;
}
&lt;/style&gt;

&lt;!--Logo和版权--&gt;
&lt;script&gt;
window.onload = function(){
var avatar=document.querySelector(&quot;.item img&quot;)
var footer=document.querySelector(&quot;div.is-size-7&quot;)
footer.innerHTML=&quot;萌ICP备20230322号&quot;
footer.style.visibility=&quot;visible&quot;
avatar.src=&quot;picture&quot;
avatar.style.visibility=&quot;visible&quot;
}
&lt;/script&gt;
</description>
</item>
<item rdf:about="https://dwt.life/archives/321/">
<title>nodejs Playwright+express 截图显示</title>
<link>https://dwt.life/archives/321/</link>
<dc:date>2023-02-12T20:26:53+08:00</dc:date>
<description>以下是一个使用Playwright和Express框架创建简单Web应用程序的示例代码。该应用程序在前台显示一个页面，该页面使用Playwright在浏览器中自动化执行一些操作，并将结果返回给页面。const express = require(&#039;express&#039;);
const { chromium } = require(&#039;playwright&#039;);

const app = express();

app.get(&#039;/&#039;, async (req, res) =&gt; {
  const browser = await chromium.launch();
  const page = await browser.newPage();

  await page.goto(&#039;https://www.example.com&#039;);
  const title = await page.title();
  const screenshot = await page.screenshot({ fullPage: true });

  await browser.close();

  res.send(`
    &lt;h1&gt;${title}&lt;/h1&gt;
    &lt;img src=&quot;data:image/png;base64,${screenshot.toString(&#039;base64&#039;)}&quot; /&gt;
  `);
});

app.listen(3000, () =&gt; {
  console.log(&#039;App listening on port 3000!&#039;);
});</description>
</item>
<item rdf:about="https://dwt.life/archives/320/">
<title>PHP去除LR LF等特殊字符串</title>
<link>https://dwt.life/archives/320/</link>
<dc:date>2023-01-21T20:45:11+08:00</dc:date>
<description>function clean($text)
{
    return trim(preg_replace(&quot;/(\s*[\r\n]+\s*|\s+)/&quot;, &#039; &#039;, $text));
}the first part \s[\r\n]+\s will replace any line breaks, it's leading spaces and it's tailing spaces into just one space.the second part \s+ will shrink spaces into one space.then trim() removes the leading/tailing space.</description>
</item>
<item rdf:about="https://dwt.life/archives/314/">
<title>谷歌下拉联想词接口</title>
<link>https://dwt.life/archives/314/</link>
<dc:date>2022-10-18T17:37:39+08:00</dc:date>
<description>接口一http://suggestqueries.google.com/complete/search?client=firefox&amp;q=YOURQUERY&amp;callback=接口二https://www.google.com/complete/search?client=hp&amp;hl=en&amp;sugexp=msedr&amp;gs_rn=62&amp;gs_ri=hp&amp;cp=1&amp;gs_id=9c&amp;q=a&amp;xhr=t&amp;callback=hellocallback参数可以去掉或者改成jsonp&lt;div id=&quot;output&quot;&gt;&lt;/div&gt;

&lt;script&gt;
/* this function shows the raw data */
function myAmazingFunction(data){
    document.getElementById(&#039;output&#039;).innerHTML = data;
}
&lt;/script&gt;

&lt;script src=&quot;https://www.google.com/complete/search?client=hp&amp;hl=en&amp;sugexp=msedr&amp;gs_rn=62&amp;gs_ri=hp&amp;cp=1&amp;gs_id=9c&amp;q=a&amp;xhr=t&amp;callback=hello&amp;callback=myAmazingFunction&quot;&gt;&lt;/script&gt;</description>
</item>
<item rdf:about="https://dwt.life/archives/311/">
<title>PHP ssh</title>
<link>https://dwt.life/archives/311/</link>
<dc:date>2022-09-12T17:15:08+08:00</dc:date>
<description>&lt;?php
class NiceSSH {
    // SSH Host
    private $ssh_host = &#039;myserver.example.com&#039;;
    // SSH Port
    private $ssh_port = 22;
    // SSH Server Fingerprint
    private $ssh_server_fp = &#039;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&#039;;
    // SSH Username
    private $ssh_auth_user = &#039;username&#039;;
    // SSH Public Key File
    private $ssh_auth_pub = &#039;/home/username/.ssh/id_rsa.pub&#039;;
    // SSH Private Key File
    private $ssh_auth_priv = &#039;/home/username/.ssh/id_rsa&#039;;
    // SSH Private Key Passphrase (null == no passphrase)
    private $ssh_auth_pass;
    // SSH Connection
    private $connection;
   
    public function connect() {
        if (!($this-&gt;connection = ssh2_connect($this-&gt;ssh_host, $this-&gt;ssh_port))) {
            throw new Exception(&#039;Cannot connect to server&#039;);
        }
        $fingerprint = ssh2_fingerprint($this-&gt;connection, SSH2_FINGERPRINT_MD5 | SSH2_FINGERPRINT_HEX);
        if (strcmp($this-&gt;ssh_server_fp, $fingerprint) !== 0) {
            throw new Exception(&#039;Unable to verify server identity!&#039;);
        }
        if (!ssh2_auth_pubkey_file($this-&gt;connection, $this-&gt;ssh_auth_user, $this-&gt;ssh_auth_pub, $this-&gt;ssh_auth_priv, $this-&gt;ssh_auth_pass)) {
            throw new Exception(&#039;Autentication rejected by server&#039;);
        }
    }
    public function exec($cmd) {
        if (!($stream = ssh2_exec($this-&gt;connection, $cmd))) {
            throw new Exception(&#039;SSH command failed&#039;);
        }
        stream_set_blocking($stream, true);
        $data = &quot;&quot;;
        while ($buf = fread($stream, 4096)) {
            $data .= $buf;
        }
        fclose($stream);
        return $data;
    }
    public function disconnect() {
        $this-&gt;exec(&#039;echo &quot;EXITING&quot; &amp;&amp; exit;&#039;);
        $this-&gt;connection = null;
    }
    public function __destruct() {
        $this-&gt;disconnect();
    }
}
?&gt;</description>
</item>
<item rdf:about="https://dwt.life/archives/308/">
<title>PHP Google merchant 添加商品</title>
<link>https://dwt.life/archives/308/</link>
<dc:date>2022-09-04T12:13:00+08:00</dc:date>
<description>&lt;?php
require_once &#039;vendor/autoload.php&#039;;

putenv(&#039;GOOGLE_APPLICATION_CREDENTIALS=Merchant-Center-XXXXXx.json&#039;);

$client = new Google_Client();
$client-&gt;useApplicationDefaultCredentials();

$client-&gt;addScope(&#039;https://www.googleapis.com/auth/content&#039;);

$service = new Google_Service_ShoppingContent($client);

$product = new Google_Service_ShoppingContent_Product();
$product-&gt;setOfferId(&#039;book123&#039;);
$product-&gt;setTitle(&#039;A Tale of Two Cities&#039;);
$product-&gt;setDescription(&#039;A classic novel about the French Revolution&#039;);
$product-&gt;setLink(&#039;http://my-book-shop.com/tale-of-two-cities.html&#039;);
$product-&gt;setImageLink(&#039;http://my-book-shop.com/tale-of-two-cities.jpg&#039;);
$product-&gt;setContentLanguage(&#039;en&#039;);
$product-&gt;setTargetCountry(&#039;GB&#039;);
$product-&gt;setChannel(&#039;online&#039;);
$product-&gt;setAvailability(&#039;in stock&#039;);
$product-&gt;setCondition(&#039;new&#039;);
$product-&gt;setGoogleProductCategory(&#039;Media &gt; Books&#039;);
$product-&gt;setGtin(&#039;9780007350896&#039;);

$price = new Google_Service_ShoppingContent_Price();
$price-&gt;setValue(&#039;2.50&#039;);
$price-&gt;setCurrency(&#039;GBP&#039;);

$shipping_price = new Google_Service_ShoppingContent_Price();
$shipping_price-&gt;setValue(&#039;0.99&#039;);
$shipping_price-&gt;setCurrency(&#039;GBP&#039;);

$shipping = new Google_Service_ShoppingContent_ProductShipping();
$shipping-&gt;setPrice($shipping_price);
$shipping-&gt;setCountry(&#039;GB&#039;);
$shipping-&gt;setService(&#039;Standard shipping&#039;);

$shipping_weight = new Google_Service_ShoppingContent_ProductShippingWeight();
$shipping_weight-&gt;setValue(200);
$shipping_weight-&gt;setUnit(&#039;grams&#039;);

$product-&gt;setPrice($price);
$product-&gt;setShipping(array($shipping));
$product-&gt;setShippingWeight($shipping_weight);

$result = $service-&gt;products-&gt;insert($merchant_id, $product);</description>
</item>
<item rdf:about="https://dwt.life/archives/271/">
<title>ActiveCMS数据库批量开启state和city</title>
<link>https://dwt.life/archives/271/</link>
<dc:date>2022-08-24T21:52:27+08:00</dc:date>
<description>UPDATE `states` SET `status`=1 where country_id = 13UPDATE `cities` as city join states state on city.state_id = state.id SET city.`status`=1 where state.country_id = 13</description>
</item>
</rdf:RDF>