|
本帖最后由 zhouchanglin 于 2014-6-7 09:30 编辑
火车头实现百度空间相册批量上传,需php接口发布;
功能:通过火车头采集图片资源,做发布接口实现相册图片的上传,相册根据是否存在可自动创建;
百度自己有flash图片上传插件,我这个是用火车头去上传的,在有些地方通过采集变得灵活很多,比较感兴趣所以做这个接口。
下面就简单说下抓包步骤:
1.图片上传- POST http://up.xiangce.baidu.com/picture/upload HTTP/1.1
- Accept: */*
- Accept-Language: zh-CN
- Referer: http://xiangce.baidu.com/static/picture/uploadpage/swf/fp10_9f5f015c.swf
- x-flash-version: 11,2,202,228
- Content-Type: multipart/form-data; boundary=wxygxkbcocmumxtvfwflwuuubbxrcsgj
- Cache-Control: no-cache
- --wxygxkbcocmumxtvfwflwuuubbxrcsgj
- Content-Disposition: form-data; name="oid"
- 0
- --wxygxkbcocmumxtvfwflwuuubbxrcsgj
- Content-Disposition: form-data; name="BDUSS"
- 1N-SDBsSddDdvRjJffYQWdXUld0dzZwUTJiZHRSQVFBQUFBJCQAAAAAAAAAAAoqyysVgJYtbWFpbGVyNgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAYIArMAAAALDmpHIAAAAA6p5DAAAAAAAxMC4yNi4yMjYf7lA2H-5QS
- --wxygxkbcocmumxtvfwflwuuubbxrcsgj
- Content-Disposition: form-data; name="batch_id"
- 1357786369
- --wxygxkbcocmumxtvfwflwuuubbxrcsgj
- Content-Disposition: form-data; name="bdstoken"
- 4e15a9ee791cb400
- --wxygxkbcocmumxtvfwflwuuubbxrcsgj
- Content-Disposition: form-data; name="picture_num"
- 1
- --wxygxkbcocmumxtvfwflwuuubbxrcsgj
- Content-Disposition: form-data; name="from"
- flash
- --wxygxkbcocmumxtvfwflwuuubbxrcsgj
- Content-Disposition: form-data; name="file_name"
- 002.jpg
- --wxygxkbcocmumxtvfwflwuuubbxrcsgj
- Content-Disposition: form-data; name="album_sign"
- d2f7d8769dd3d0ed872ff4dc6a23826c7bde5d78
- --wxygxkbcocmumxtvfwflwuuubbxrcsgj
- Content-Disposition: form-data; name="upload"; filename="[文件名2:本地图片]"
- Content-Type: application/octet-stream
- [文件源码:本地图片]
- --wxygxkbcocmumxtvfwflwuuubbxrcsgj
- Content-Disposition: form-data; name="Upload"
- Submit Query
- --wxygxkbcocmumxtvfwflwuuubbxrcsgj
- Content-Disposition: form-data; name="exif"; filename="exif.jpg"
- Content-Type: application/octet-stream
- --wxygxkbcocmumxtvfwflwuuubbxrcsgj
- Content-Disposition: form-data; name="Upload"
- Submit Query
- --wxygxkbcocmumxtvfwflwuuubbxrcsgj--
- 返回:{ "status":{"code": "0","msg": "ok" }, "data": {"thumbnail":.........
复制代码 2.相册创建- //相册创建
- POST http://xiangce.baidu.com/album/submit/add HTTP/1.1
- x-requested-with: XMLHttpRequest
- Accept-Language: zh-CN
- Referer: http://xiangce.baidu.com/picture/page/upload
- Accept: */*
- Content-Type: application/x-www-form-urlencoded; charset=UTF-8
- Accept-Encoding: gzip, deflate
- album_name=%E6%98%8E%E6%98%9F&bdstoken=7b0a60186d09c000
- HTTP/1.1 200 OK
- Content-Type: application/json; charset=utf-8;
- Date: Fri, 11 Jan 2013 00:04:31 GMT
- Server: apache
- Content-Length: 135
- 返回:{ "status":{"code": "0","msg": "success" }, "data": {"album_sign":"b849c9c3008600d67c887ae3856098dfd73d0eb5","create_time":1357862671}}
复制代码 该步抓包简单说明:
album_sign":"b849c9c3008600d67c887ae3856098dfd73d0eb5"-------这个是相册的标示id;
album_name=%E6%98%8E%E6%98%9F-----------相册名
bdstoken=7b0a60186d09c000----------------用户相关变量
自动登录,相册自动创建,通过php接口模拟就可以实现这些功能了,有很多变量的获取还是比较复杂的;
总结:用火车头上传图片,虽然可能稳定性不路百度提供的flash,但灵活很多 ,对于一些图片营销也许有些效果吧。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?加入会员
x
|