我找到的所有有关创建Picasa相册和上传图片的教程都使用了我没有学过的Zend Framework。
是否可能使用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
的相册并将图片上传到其中吗?
编辑1:
如何在使用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"
},
$imgData = file_get_contents("$direct_img_url")
但没有元数据,为什么它不起作用呢? - Khurshid Alam