<jupyter_start><jupyter_text>確定有 publish 的權限https://developers.facebook.com/tools/explorer<jupyter_code>token = input()
import facebook
graph = facebook.GraphAPI(token, version="2.7")
%pylab inline
pylab.rcParams['figure.figsize'] = (15, 10)
img = zeros(shape=(1024,1024,3))
Y, X = ogrid[0:1024,0:1024]
img = zeros(shape=(1024,1024,3))
x=y=0.
for k in range(15):
    x, y = (sin(x)) - cos(y)**2 +(X-512.)/512, 2*sin(x)*cos(y)+(Y-512.0)/512;
img[:,:,0] = x**2+y**2
img[:,:,1] = 15*abs(x)
img[:,:,2] = 15*abs(y)
imshow(img/2);
imsave("foo.png", img/2)
imshow(imread('foo.png'))
import json
privacy = json.dumps({"value": "SELF"})
graph.put_photo(image=open('foo.png', 'rb'), caption='generated using python', privacy=privacy)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.23771580345285526, 'fraction_numerical': 0.08366533864541832, 'mean_word_length': 7.0212765957446805, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '316117', 'license': 'MIT', 'n_tokens_mistral': 368, 'n_tokens_neox': 331, 'n_words': 53, 'path': 'Week09/03-facebook-post.ipynb', 'repo_name': 'HowardNTUST/HackNTU_Data_2017', 'size': '753'}