Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Education
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
Education
Commits
75792329
Commit
75792329
authored
Feb 07, 2022
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取公众号成功发布的文章
parent
d619a18d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
0 deletions
+84
-0
SchoolGardenController.cs
...bApi/Controllers/LearningGarden/SchoolGardenController.cs
+84
-0
No files found.
Edu.WebApi/Controllers/LearningGarden/SchoolGardenController.cs
View file @
75792329
...
...
@@ -340,6 +340,90 @@ namespace Edu.WebApi.Controllers.LearningGarden
}
return
list
;
}
/// <summary>
/// 获取成功发布列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <returns></returns>
static
List
<
WeChatLearningGardenItem
>
GetFreePublishList
(
int
pageIndex
,
int
pageSize
)
{
string
tokenKey
=
Cache
.
CacheKey
.
DATA_WeChatAccountToken
+
Common
.
Config
.
WeChatAccountAppId
;
string
token
=
Cache
.
WeChat
.
WeChatReidsCache2
.
GetToken
(
tokenKey
);
if
(
Common
.
Config
.
IsLocal
==
1
)
{
token
=
"53_yZLlrwCr1CVh5TjyS1FkarF5M15NfYEmMFvtJKVA0C_R5tzOE20CZlFvWOWQRoezFQDweQPwkcenlISyEXoFkOpljNvyt-0_uXvtqQW41T7HfJnFGUWBGNIDkUQuFkKQWTpdXvdZhbWWeE_kMTTcAEAPWW"
;
}
if
(
string
.
IsNullOrEmpty
(
token
))
{
token
=
Common
.
Plugin
.
WeChatHelper
.
GetAccessToken
(
Common
.
Config
.
WeChatAccountAppId
,
Common
.
Config
.
WeChatAccountAppSecret
);
Cache
.
WeChat
.
WeChatReidsCache2
.
Set
(
tokenKey
,
token
);
}
string
newImaApi
=
"https://api.weixin.qq.com/cgi-bin/freepublish/batchget?access_token="
+
token
;
List
<
WeChatLearningGardenItem
>
list
=
new
List
<
WeChatLearningGardenItem
>();
var
resultInfo
=
new
{
count
=
pageSize
,
offset
=
(
pageIndex
-
1
)
*
pageSize
,
no_content
=
pageSize
};
string
jsonData
=
HttpHelper
.
HttpPost
(
newImaApi
,
JsonHelper
.
Serialize
(
resultInfo
),
""
);
if
(
jsonData
!=
null
&&
!
string
.
IsNullOrEmpty
(
jsonData
))
{
Common
.
Plugin
.
LogHelper
.
WriteInfo
(
"GetVoiceData: "
+
jsonData
);
JObject
jObj
=
JObject
.
Parse
(
jsonData
);
var
item
=
jObj
.
GetStringValue
(
"item"
);
if
(!
string
.
IsNullOrEmpty
(
item
))
{
JArray
jArray
=
JArray
.
Parse
(
item
);
if
(
jArray
!=
null
&&
jArray
.
Count
>
0
)
{
foreach
(
var
jItem
in
jArray
)
{
JObject
sObj
=
JObject
.
Parse
(
jItem
.
ToString
());
JObject
dObj
=
JObject
.
Parse
(
sObj
.
GetStringValue
(
"content"
));
var
newsItem
=
new
List
<
WeChatLearningGardenNewsItem
>();
JArray
subArray
=
JArray
.
Parse
(
dObj
.
GetStringValue
(
"news_item"
));
if
(
subArray
!=
null
&&
subArray
.
Count
>
0
)
{
foreach
(
var
sItem
in
subArray
)
{
var
contentObj
=
JObject
.
Parse
(
sItem
.
ToString
());
newsItem
.
Add
(
new
WeChatLearningGardenNewsItem
()
{
title
=
contentObj
.
GetStringValue
(
"title"
),
author
=
contentObj
.
GetStringValue
(
"author"
),
digest
=
contentObj
.
GetStringValue
(
"digest"
),
content
=
contentObj
.
GetStringValue
(
"content"
),
show_cover_pic
=
contentObj
.
GetInt
(
"show_cover_pic"
),
url
=
contentObj
.
GetStringValue
(
"url"
),
thumb_url
=
contentObj
.
GetStringValue
(
"thumb_url"
),
});
}
}
var
content
=
new
WeChatLearningGardenContent
()
{
news_item
=
newsItem
,
create_time
=
dObj
.
GetLong
(
"create_time"
),
update_time
=
dObj
.
GetLong
(
"update_time"
),
};
WeChatLearningGardenItem
model
=
new
WeChatLearningGardenItem
()
{
media_id
=
sObj
.
GetStringValue
(
"article_id"
),
update_time
=
sObj
.
GetStringValue
(
"update_time"
),
content
=
content
};
list
.
Add
(
model
);
}
}
}
}
return
list
;
}
#
endregion
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment