質問編集履歴

16

修正

2016/06/16 10:21

投稿

horik
horik

スコア44

test CHANGED
File without changes
test CHANGED
@@ -56,7 +56,7 @@
56
56
 
57
57
  data = {
58
58
 
59
- 'massage': '今日のディナー',
59
+ 'message': '今日のディナー',
60
60
 
61
61
  'attached_media[0]': {'media_fbid': resp1['id']},
62
62
 

15

修正

2016/06/16 10:21

投稿

horik
horik

スコア44

test CHANGED
File without changes
test CHANGED
@@ -42,13 +42,11 @@
42
42
 
43
43
  ```
44
44
 
45
- さらにsdkを使わずにpostメソッドを送ってみたら以下のエラーが返りました。
45
+ さらにsdkを使わずにpostメソッドを送ってみたら同じエラーが返りました。
46
46
 
47
47
  ```json
48
48
 
49
- {"error":{"message":"The post is empty. Please enter a message to share.","type":"OAuthException","code":197,"error_subcode":1455004,"is_transient":false,"error_user_title":"Status Is Empty","error_user_msg":"This status update appears to be blank. Please write something or attach a link or photo to update your status.","fbtrace_id":"ChmFpZfyHD1"}}
50
-
51
-
49
+ {"error":{"message":"An unknown error has occurred.","type":"OAuthException","code":1,"fbtrace_id":"CHl2myso+t0"}}
52
50
 
53
51
  ```
54
52
 

14

追記

2016/06/16 10:20

投稿

horik
horik

スコア44

test CHANGED
File without changes
test CHANGED
@@ -42,6 +42,44 @@
42
42
 
43
43
  ```
44
44
 
45
+ さらにsdkを使わずにpostメソッドを送ってみたら以下のエラーが返りました。
46
+
47
+ ```json
48
+
49
+ {"error":{"message":"The post is empty. Please enter a message to share.","type":"OAuthException","code":197,"error_subcode":1455004,"is_transient":false,"error_user_title":"Status Is Empty","error_user_msg":"This status update appears to be blank. Please write something or attach a link or photo to update your status.","fbtrace_id":"ChmFpZfyHD1"}}
50
+
51
+
52
+
53
+ ```
54
+
55
+ ```python
56
+
57
+ import requests
58
+
59
+ data = {
60
+
61
+ 'massage': '今日のディナー',
62
+
63
+ 'attached_media[0]': {'media_fbid': resp1['id']},
64
+
65
+ 'attached_media[1]': {'media_fbid': resp2['id']},
66
+
67
+ 'access_token': 'ここにアクセストークンが入る',
68
+
69
+ }
70
+
71
+ r = requests.post(
72
+
73
+ url='https://graph.facebook.com/v2.4/me/feed',
74
+
75
+ data=data,
76
+
77
+ )
78
+
79
+ print(r.text)
80
+
81
+ ```
82
+
45
83
  image.jpgとimage2.jpgを同時に1つの記事として投稿するにはどうすればいいでしょうか?
46
84
 
47
85
  詳しい方がおられましたらご教示お願いします。

13

修正

2016/06/16 09:56

投稿

horik
horik

スコア44

test CHANGED
File without changes
test CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
  ```
26
26
 
27
- [公式ドキュメント](https://developers.facebook.com/docs/graph-api/photo-uploads)を参考に以下を試しましたが
27
+ [公式ドキュメント](https://developers.facebook.com/docs/graph-api/photo-uploads)を参考に以下を試しましたが3行目で
28
28
 
29
29
  facebook.GraphAPIError: An unknown error has occurred.
30
30
 

12

修正

2016/06/16 01:38

投稿

horik
horik

スコア44

test CHANGED
File without changes
test CHANGED
@@ -32,11 +32,11 @@
32
32
 
33
33
  ```python
34
34
 
35
- resp1 = graph.request('/me/photos', post_args={'url': 'http://localhost/image.jpg', 'published': 'false'})
35
+ resp1 = GraphAPI.request('/me/photos', post_args={'url': 'http://localhost/image.jpg', 'published': 'false'})
36
36
 
37
- resp2 = graph.request('/me/photos', post_args={'url': 'http://localhost/image2.jpg', 'published': 'false'})
37
+ resp2 = GraphAPI.request('/me/photos', post_args={'url': 'http://localhost/image2.jpg', 'published': 'false'})
38
38
 
39
- graph.request('/me/feed', post_args={'message': '今日のディナー', 'attached_media[0]': {'media_fbid': resp1['id']}, 'attached_media[1]': {'media_fbid': resp2['id']}})
39
+ GraphAPI.request('/me/feed', post_args={'message': '今日のディナー', 'attached_media[0]': {'media_fbid': resp1['id']}, 'attached_media[1]': {'media_fbid': resp2['id']}})
40
40
 
41
41
 
42
42
 

11

 修正

2016/06/16 01:36

投稿

horik
horik

スコア44

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- [faceboo-sdk](https://github.com/mobolic/facebook-sdk)で複数の画像付きの投稿がしたいと思っています。
1
+ [facebook-sdk](https://github.com/mobolic/facebook-sdk)で複数の画像付きの投稿がしたいと思っています。
2
2
 
3
3
 
4
4
 

10

修正

2016/06/16 01:32

投稿

horik
horik

スコア44

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,4 @@
1
- pip install facebook-sdk
2
-
3
- で複数の画像付きの投稿がしたいと思っています。
1
+ [faceboo-sdk](https://github.com/mobolic/facebook-sdk)で複数の画像付きの投稿がしたいと思っています。
4
2
 
5
3
 
6
4
 

9

修正

2016/06/16 01:31

投稿

horik
horik

スコア44

test CHANGED
File without changes
test CHANGED
@@ -26,7 +26,7 @@
26
26
 
27
27
  ```
28
28
 
29
- [公式ドキュメント](https://developers.facebook.com/docs/graph-api/photo-uploads)を参考に試しましたが
29
+ [公式ドキュメント](https://developers.facebook.com/docs/graph-api/photo-uploads)を参考に以下を試しましたが
30
30
 
31
31
  facebook.GraphAPIError: An unknown error has occurred.
32
32
 
@@ -34,11 +34,11 @@
34
34
 
35
35
  ```python
36
36
 
37
- resp1 = graph.request('/me/photos', post_args={'caption': '', 'url': 'http://localhost/image.jpg', 'published': 'false'})
37
+ resp1 = graph.request('/me/photos', post_args={'url': 'http://localhost/image.jpg', 'published': 'false'})
38
38
 
39
- resp2 = graph.request('/me/photos', post_args={'caption': '', 'url': 'http://localhost/image2.jpg', 'published': 'false'})
39
+ resp2 = graph.request('/me/photos', post_args={'url': 'http://localhost/image2.jpg', 'published': 'false'})
40
40
 
41
- graph.request('/me/feed', method='post', post_args={'message': '今日のディナー', 'attached_media[0]': {'media_fbid': resp1['id']}, 'attached_media[1]': {'media_fbid': resp2['id']}})
41
+ graph.request('/me/feed', post_args={'message': '今日のディナー', 'attached_media[0]': {'media_fbid': resp1['id']}, 'attached_media[1]': {'media_fbid': resp2['id']}})
42
42
 
43
43
 
44
44
 

8

追記

2016/06/16 01:29

投稿

horik
horik

スコア44

test CHANGED
File without changes
test CHANGED
@@ -26,6 +26,24 @@
26
26
 
27
27
  ```
28
28
 
29
+ [公式ドキュメント](https://developers.facebook.com/docs/graph-api/photo-uploads)を参考に試しましたが
30
+
31
+ facebook.GraphAPIError: An unknown error has occurred.
32
+
33
+ というエラーが返ってきました。
34
+
35
+ ```python
36
+
37
+ resp1 = graph.request('/me/photos', post_args={'caption': '', 'url': 'http://localhost/image.jpg', 'published': 'false'})
38
+
39
+ resp2 = graph.request('/me/photos', post_args={'caption': '', 'url': 'http://localhost/image2.jpg', 'published': 'false'})
40
+
41
+ graph.request('/me/feed', method='post', post_args={'message': '今日のディナー', 'attached_media[0]': {'media_fbid': resp1['id']}, 'attached_media[1]': {'media_fbid': resp2['id']}})
42
+
43
+
44
+
45
+ ```
46
+
29
47
  image.jpgとimage2.jpgを同時に1つの記事として投稿するにはどうすればいいでしょうか?
30
48
 
31
49
  詳しい方がおられましたらご教示お願いします。

7

修正

2016/06/16 01:26

投稿

horik
horik

スコア44

test CHANGED
File without changes
test CHANGED
@@ -26,6 +26,6 @@
26
26
 
27
27
  ```
28
28
 
29
- image1.jpgとimage2.jpgを同時に1つの記事として投稿するにはどうすればいいでしょうか?
29
+ image.jpgとimage2.jpgを同時に1つの記事として投稿するにはどうすればいいでしょうか?
30
30
 
31
31
  詳しい方がおられましたらご教示お願いします。

6

修正

2016/06/15 16:07

投稿

horik
horik

スコア44

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- このコードだと1つの画像しか添付できませんでした
7
+ このコードだと1つの画像しか添付できません。
8
8
 
9
9
  ```python
10
10
 
@@ -18,8 +18,14 @@
18
18
 
19
19
  ```python
20
20
 
21
+ image1 = open('image.jpg', 'rb')
22
+
23
+ image2 = open('image2.jpg', 'rb')
24
+
21
- GraphAPI.request('/me/photos', post_args={'message': '今日のディナー'}, files={'source': [open('image.jpg', 'rb'), open('image2.jpg', 'rb')]})
25
+ GraphAPI.request('/me/photos', post_args={'message': '今日のディナー'}, files={'source': [image1, image2]})
22
26
 
23
27
  ```
24
28
 
29
+ image1.jpgとimage2.jpgを同時に1つの記事として投稿するにはどうすればいいでしょうか?
30
+
25
31
  詳しい方がおられましたらご教示お願いします。

5

修正

2016/06/15 16:06

投稿

horik
horik

スコア44

test CHANGED
File without changes
test CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
  ```python
20
20
 
21
- GraphAPI.request('/me/photos', post_args={'message': '今日のディナー', files={'source': [open('image.jpg', 'rb'), open('image2.jpg', 'rb')]})
21
+ GraphAPI.request('/me/photos', post_args={'message': '今日のディナー'}, files={'source': [open('image.jpg', 'rb'), open('image2.jpg', 'rb')]})
22
22
 
23
23
  ```
24
24
 

4

修正

2016/06/15 15:59

投稿

horik
horik

スコア44

test CHANGED
File without changes
test CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  ライブラリの中を探っていくとput_photoはrequestを呼び出しているようだったので、
16
16
 
17
- 見よう見まねで以下のようにしてみましたが、全く画像を投稿できせんでした。
17
+ 見よう見まねで以下のようにしてみましたが、image2.jpgのみ投稿されました。
18
18
 
19
19
  ```python
20
20
 

3

修正

2016/06/15 15:58

投稿

horik
horik

スコア44

test CHANGED
File without changes
test CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
  ```python
20
20
 
21
- GraphAPI.request('/me/feed', post_args={'message': '今日のディナー', files={'image.jpg': open('image.jpg', 'rb')})
21
+ GraphAPI.request('/me/photos', post_args={'message': '今日のディナー', files={'source': [open('image.jpg', 'rb'), open('image2.jpg', 'rb')]})
22
22
 
23
23
  ```
24
24
 

2

微修正

2016/06/15 15:57

投稿

horik
horik

スコア44

test CHANGED
File without changes
test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  ```python
10
10
 
11
- GraphAPI.put_photo(open(tmp1.name, 'rb'), message='今日のディナー')
11
+ GraphAPI.put_photo(open('image.jpg', 'rb'), message='今日のディナー')
12
12
 
13
13
  ```
14
14
 

1

微修正

2016/06/15 15:47

投稿

horik
horik

スコア44

test CHANGED
File without changes
test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  ```python
10
10
 
11
- graph.put_photo(open(tmp1.name, 'rb'), message='今日のディナー')
11
+ GraphAPI.put_photo(open(tmp1.name, 'rb'), message='今日のディナー')
12
12
 
13
13
  ```
14
14
 
@@ -18,7 +18,7 @@
18
18
 
19
19
  ```python
20
20
 
21
- graph.request('/me/feed', post_args={'message': '今日のディナー', files={'image.jpg': open('image.jpg', 'rb')})
21
+ GraphAPI.request('/me/feed', post_args={'message': '今日のディナー', files={'image.jpg': open('image.jpg', 'rb')})
22
22
 
23
23
  ```
24
24