公開するためには手動で承認作業が必要。
fb_image_upload.sh
#!/bin/bash if [ "$#" -eq 0 ];then echo "Do not get image. " else echo " Get image. "$1 /opt/local/bin/python2.5 get_image.py $1 fi msg="test" caption="message="$msg"" token=`cat .fb_access_token` echo $caption echo $token echo `curl -F "access_token="$token"" -F "source=@"dummy.jpg"" -F "$caption" https://graph.facebook.com/me/photos`alubm ID によりアルバムを指定して post することもできるが、この場合も公開には承認作業が必要。
echo `curl -F "access_token="$token"" -F "source=@"dummy.jpg"" -F "$caption" https://graph.facebook.com/10150411507966880/photos`アプリケーションで自動作成されるアルバムには1000枚まで写真が保存できるみたいです。
https://graph.facebook.com/ALBUM_ID/photos - The photo will be published to a specific, existing photo album, represented by the ALBUM_ID. Regular albums have a size limit of 200 photos. Default application albums have a size limit of 1000 photos. https://developers.facebook.com/docs/reference/api/photo/関連
画像の取得 get_image.py
#!-*- coding:utf-8 -*-
#!/opt/local/bin/python2.5
import sys
import urllib
import httplib
import cStringIO
import ImageFile
from PIL import Image, ImageDraw, ImageFont
import string
import re
url = "http://xxx/xxx.jpg"
file = urllib.urlopen(url)
try:
size = file.headers.get("content-length")
print "size:" + size
im = cStringIO.StringIO(file.read())
img = Image.open(im)
except:
print "Error: Url = " + url
img_type = "jpg"
img_file = url
if img_file[-3:] == "PNG" or img_file[-3:] == "png":
img_type = "png"
img.save("dummy."+ img_type,"PNG")
elif img_file[-3:] == "GIF" or img_file[-3:] == "gif":
img_type = "gif"
img.save("dummy."+ img_type,"GIF")
else:
img.save("dummy."+ img_type,"JPEG")