【发布时间】:2012-03-23 23:20:20
【问题描述】:
我发现的所有创建 Picasa 相册和上传图片的教程都使用了我没有研究过的 Zend 框架。
是否可以使用 PHP 和 cURL 上传图片和创建相册?
我的图片存储在e:/images目录中,图片信息存储在一个MySQL表中,如下所示:
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE TABLE IF NOT EXISTS `picasaimage` (
`id` bigint(1) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`content` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`tags` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`license` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`image_path` varchar(150) COLLATE utf8_unicode_ci NOT NULL,
`width` int(4) COLLATE utf8_unicode_ci NOT NULL,
`height` int(4) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=0 ;
我正在使用以下代码获取 Google 客户端身份验证代码:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.google.com/accounts/ClientLogin");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = array('accountType' => 'GOOGLE',
'Email' => 'youremailaddress@gmail.com',
'Passwd' => 'yourpassword',
'source'=>'PHI-cUrl-Example',
'service'=>'lh2');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$hasil = curl_exec($ch);
echo $hasil;
//SID=DQA...oUE
//LSID=DQA...bbo
//Auth=DQA...Sxq
?>
谁能提供一些关于创建名为test 的相册并将图像上传到其中的指导?
EDIT1:
使用php脚本上传照片时如何添加照片许可?
参考http://commons.wikimedia.org/wiki/Commons:Picasa_Web_Albums_files
Creative Commons Attribution 3.0 Unported (CC-BY)
Creative Commons Attribution-Share Alike 3.0 Unported
Unlicensed
Creative Commons Attribution-Noncommercial 3.0 Unported
Creative Commons Attribution-No Derivative Works 3.0 Unported
Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported
查看api获取相册照片的响应数据,应该有这样的:
"gphoto$license":{
"$t":"ATTRIBUTION_NON_COMMERCIAL_NO_DERIVATIVES",
"id":3,
"name":"Attribution-Noncommercial-No Derivative",
"url":"http://creativecommons.org/licenses/by-nc-nd/3.0"
},
【问题讨论】: