Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何将google表单电子表格数据插入wordpress数据库?_Php_Wordpress_Curl - Fatal编程技术网

Php 如何将google表单电子表格数据插入wordpress数据库?

Php 如何将google表单电子表格数据插入wordpress数据库?,php,wordpress,curl,Php,Wordpress,Curl,我搜索过谷歌并实现了这段代码,但它给出了 警告:DOMDocument::loadXML():开始和结束标记不匹配:第36行的/home/etplpm/public_html/netsamningar/wp content/thestory/template-login.php中的链接第2行和head-in实体第94行。 我已经根据我的文档更改了Url和密钥,但找不到任何合适的解决方案 $key = "...key..."; $url = "https://docs.google.

我搜索过谷歌并实现了这段代码,但它给出了 警告:DOMDocument::loadXML():开始和结束标记不匹配:第36行的/home/etplpm/public_html/netsamningar/wp content/thestory/template-login.php中的链接第2行和head-in实体第94行。 我已经根据我的文档更改了Url和密钥,但找不到任何合适的解决方案

   $key = "...key...";

   $url = "https://docs.google.com/spreadsheets/d/...key.../pubhtml";

   $ch = curl_init();

   // set URL and other appropriate options
   curl_setopt($ch, CURLOPT_URL, $url);
   curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

  // grab URL and pass it to the browser
  $google_sheet = curl_exec($ch);

  // close cURL resource, and free up system resources
   curl_close($ch);

   $doc = new DOMDocument();
   $doc->loadXML($google_sheet); 

   $nodes = $doc->getElementsByTagName("cell");

   if($nodes->length > 0)
   {
       foreach($nodes as $node)
      {
           // 2nd row is the email row.
           if ($node->getAttribute("row") == 2)
          {
               if (eregi("^[\.\+_a-z0-9-]+@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$", $node->nodeValue) ) 
               {
                     mail($node->nodeValue, "Mail Subject", "Mail Message.", "From: email@yourdomain.com");
              }

           }
       }
   }