我想使用一个php脚本,已经处理我的谷歌产品饲料,也创建了一个冰产品饲料,这应该只是一个制表符分隔的文本文件…到目前为止,我只能让bing在测试时识别文件中的"2“列。我怀疑这是因为他们需要一个utf-8编码的"DOS格式“文本文件。到目前为止,我有这样的想法:
打开用于源的文件:
$bing = fopen('bing_products.txt','ab');创建标题行:
$header_row="MPID Title BrandorManufacturer MerchantSKU ProductURL Price StockStatus Description ImageURL BingCategory Condition\r\n";遍历产品:
$bing_text.=bing_simpl($item_number)." ";
$bing_text.=bing_simpl($name." color ".substr($item_number, 3,4)." size ".$unit_of_measure)." ";
$bing_text.=bing_simpl($manufacturer)." ";
$bing_text.=bing_simpl($item_number)." "; $bing_text.="https://example.com/".$general_category."/".strtolower($item_no_three)." ";
$bing_text.=number_format($price_one,2)." ";
$bing_text.="In Stock ";
$bing_text.=bing_simpl($descript." color ".substr($item_number, 3,4)." size ".$unit_of_measure)." ";
$bing_text.=$image_url." ";
$bing_text.=$general_category.">".simpl($craft).">".simpl($key_word_i)." ";
$bing_text.= "New\r\n";写入并关闭文件:
fwrite($bing, $header_row.$bing_text);fclose($bing);可以选择添加UTF-8字节码:
$str=file_get_contents('bing_products.txt');
file_put_contents('bing_products.txt',"\xEF\xBB\xBF".$str);"bing_simpl“和"canonical_name”去掉了任何无关的格式。我尝试过使用"\t“作为选项卡。我在没有file_get_contents /file_put_contents的情况下尝试过...测试用PHP编码的文件返回ASCII码(实际上应该是UTF-8,我正在处理一个从FileMaker导出的xml文件)。
我错过了什么简单的东西吗?
更新似乎部分问题与使用gzip或finder的" compress“函数来压缩提要文件有关。也就是说,我可以得到一个截断的,未压缩版本的文件,可以正常工作(必须足够小,以便与bing的“测试”形式一起工作)。如果我能找到使用压缩版本的变通方法,我会更新。
发布于 2015-05-15 18:59:40
必应的产品已经无缝支持Google Shopping了。http://www.cpcstrategy.com/blog/2014/04/google-feed-for-bing-shopping-product-ads/
如果您可以访问Windows机,您可以使用记事本创建一个bingproducts.txt文件,并在vim中检查标题和制表符换行符。
https://stackoverflow.com/questions/30246256
复制相似问题