質問編集履歴

1

ソースコードを抜粋して記載

2017/11/19 03:30

投稿

ebsffzal
ebsffzal

スコア107

test CHANGED
File without changes
test CHANGED
@@ -61,3 +61,99 @@
61
61
  同じような境遇にあった方や、有識者様のご意見をいただきたいと思います。
62
62
 
63
63
  何卒どうぞよろしくお願い致します。
64
+
65
+
66
+
67
+
68
+
69
+ (追記)
70
+
71
+ 実際の接続部分のソースコードを記載いたします。
72
+
73
+ 抜粋になりますので、一部変数の部分はDBアクセス等した結果が入っています。
74
+
75
+
76
+
77
+ ```php
78
+
79
+
80
+
81
+ //ライブラリ
82
+
83
+ require_once("IXR_Library.php");
84
+
85
+
86
+
87
+ //初期設定
88
+
89
+ $blog_url = 'https://xxxxxxxxxxxxxxxxxxxx/xmlrpc.php';
90
+
91
+ $user = 'aaaaaa';
92
+
93
+ $pass = 'bbbbbb';
94
+
95
+
96
+
97
+ //新規記事を自動投稿
98
+
99
+ $client = new IXR_Client($blog_url);
100
+
101
+ $status = $client->query(
102
+
103
+ "wp.newPost", // 使用する API
104
+
105
+ 1, // ブログID(通常は1)
106
+
107
+ $user, // ユーザー
108
+
109
+ $pass, // パスワード
110
+
111
+ array(
112
+
113
+ 'post_author' => $user, // 投稿者ID
114
+
115
+ 'post_date' => $post_date,
116
+
117
+ 'post_status' => 'publish', // 投稿状態(publish:公開、draft:下書き)
118
+
119
+ 'post_title' => $rs_data["title"], // タイトル
120
+
121
+ 'comment_status' => 'open', //コメントを有効にするかどうか
122
+
123
+ 'post_content' => "", // 本文
124
+
125
+ 'post_excerpt' => "", // 抜粋
126
+
127
+ 'terms_names' => array(
128
+
129
+ 'category' => $category, //カテゴリ
130
+
131
+ 'post_tag' => $tag //タグ
132
+
133
+ ),
134
+
135
+ "custom_fields" => array( //カスタムフィールドを設定する
136
+
137
+ array("key" => "site_name", "value" => $rs_data["site_name"]),
138
+
139
+ array("key" => "image_url", "value" => $image_url_array["7"]),
140
+
141
+ ),
142
+
143
+ //'wp_post_thumbnail' => $img["id"] //アイキャッチを設定する
144
+
145
+ )
146
+
147
+ );
148
+
149
+
150
+
151
+ //結果を取得
152
+
153
+ $response = $client->getResponse();
154
+
155
+ $post_id = $response;
156
+
157
+
158
+
159
+ ```