|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Facebook에 정기적으로 게시물을 올리는 경우 생산성을 높이는 가장 좋은 방법 중 하나는 자동 게시물 스케줄러를 사용하는 것입니다. 이를 수행하는 한 가지 방법은 달력이나 크론 작업에 연결할 수 있는 간단한 Python 스크립트를 만드는 것입니다. 이제 해당 스크립트를 작성하는 방법을 살펴보겠습니다.
One way to improve productivity if you regularly post to Facebook is with an automatic post scheduler. One way to do that is to create a simple Python script that you can attach to a calendar or cron job. Let’s look at creating that script now.
Facebook에 정기적으로 게시물을 올리는 경우 생산성을 높이는 한 가지 방법은 자동 게시물 스케줄러를 사용하는 것입니다. 이를 수행하는 한 가지 방법은 달력이나 크론 작업에 연결할 수 있는 간단한 Python 스크립트를 만드는 것입니다. 이제 해당 스크립트를 작성하는 방법을 살펴보겠습니다.
## Creating a Facebook app
## 페이스북 앱 만들기
Any Python script that we create to post on Facebook will use a Facebook app to do so, and you will need to make it before we can start with the Python script. Luckily, it’s not hard.
Facebook에 게시하기 위해 만드는 모든 Python 스크립트는 이를 위해 Facebook 앱을 사용하므로 Python 스크립트를 시작하기 전에 먼저 작성해야 합니다. 다행히도 어렵지 않습니다.
1. Go to the Meta Developers site and log in.
1. 메타개발자 사이트에 접속하여 로그인을 해주세요.
2. Click on “My Apps” in the top navigation bar.
2. 상단 탐색 표시줄에서 '내 앱'을 클릭하세요.
3. Click on “Create New App.”
3. '새 앱 만들기'를 클릭하세요.
4. Select “Manage Page” as the app type and click on “Continue.”
4. 앱 유형으로 '페이지 관리'를 선택하고 '계속'을 클릭하세요.
5. Enter a display name for your app and click on “Create App.”
5. 앱의 표시 이름을 입력하고 '앱 만들기'를 클릭하세요.
6. Click on “Skip Quick Start” and then on “Settings.”
6. “빠른 시작 건너뛰기”를 클릭한 다음 “설정”을 클릭하세요.
7. In the left sidebar, click on “Basic Settings.”
7. 왼쪽 사이드바에서 '기본 설정'을 클릭하세요.
8. Under “App Domains,” enter the domain name of the website or server that will be hosting your Python script. For example, if your script will be hosted on your personal website at the URL “https://example.com/script.py,” then you would enter “example.com” here.
8. "앱 도메인" 아래에 Python 스크립트를 호스팅할 웹사이트 또는 서버의 도메인 이름을 입력합니다. 예를 들어 스크립트가 개인 웹사이트 URL "https://example.com/script.py"에서 호스팅되는 경우 여기에 "example.com"을 입력합니다.
9. Click on “Save Changes.”
9. '변경사항 저장'을 클릭하세요.
10. Next, we need to add our Facebook page to the app. In the left sidebar, click on “Pages.”
10. 다음으로 Facebook 페이지를 앱에 추가해야 합니다. 왼쪽 사이드바에서 '페이지'를 클릭합니다.
11. Click on the “Add Page” button and select the page that you want to give your app permission to post on.
11. "페이지 추가" 버튼을 클릭하고 앱에 게시 권한을 부여할 페이지를 선택하세요.
12. Click on the “Assign” button and then on the “Done” button.
12. "할당" 버튼을 클릭한 후 "완료" 버튼을 클릭하세요.
13. Finally, we need to generate an access token for our app. In the left sidebar, click on “App Tokens.”
13. 마지막으로 앱에 대한 액세스 토큰을 생성해야 합니다. 왼쪽 사이드바에서 '앱 토큰'을 클릭하세요.
14. Click on the “Generate New Token” button and select “User Access Token” from the dropdown menu.
14. "새 토큰 생성" 버튼을 클릭하고 드롭다운 메뉴에서 "사용자 액세스 토큰"을 선택합니다.
15. Click on the “Generate” button and copy the access token that is displayed. You will need this token later when we configure our Python script.
15. “생성” 버튼을 클릭하고 표시된 액세스 토큰을 복사하세요. 나중에 Python 스크립트를 구성할 때 이 토큰이 필요합니다.
## Get your page ID
## 페이지 ID 받기
With the app created, we can use it as a go-between between Python and Facebook, but to make a post, we will need our page ID.
앱이 생성되면 이를 Python과 Facebook 사이를 연결하는 매개체로 사용할 수 있지만 게시물을 작성하려면 페이지 ID가 필요합니다.
1. Go to the Facebook page that you want to post on.
1. 포스팅하고 싶은 페이스북 페이지로 이동합니다.
2. In the URL address bar, look for the string of numbers that appears after “facebook.com/.” This is your page ID. For example, if the URL of your page is “https://www.facebook.com/geeksides/,” then your page ID is “geeksides.”
2. URL 주소 표시줄에서 "facebook.com/" 뒤에 나타나는 일련의 숫자를 찾으세요. 귀하의 페이지 ID입니다. 예를 들어 페이지 URL이 "https://www.facebook.com/geeksides/"인 경우 페이지 ID는 "geeksides"입니다.
## Get your page access token
## 페이지 액세스 토큰 받기
The final thing we need before we can write our Python script is our page access token.
Python 스크립트를 작성하기 전에 마지막으로 필요한 것은 페이지 액세스 토큰입니다.
1. Go to the Graph API Explorer site and log in.
1. 그래프 API 탐색기 사이트에 접속하여 로그인하세요.
2. In the left sidebar, click on “User Access Token.”
2. 왼쪽 사이드바에서 “사용자 액세스 토큰”을 클릭하세요.
3. Select the page that you want to get the access token for from the dropdown menu.
3. 드롭다운 메뉴에서 액세스 토큰을 얻으려는 페이지를 선택합니다.
4. Click on the “Generate Access Token” button and copy the access token that is displayed. You will need this token later when we configure our Python script.
4. “액세스 토큰 생성” 버튼을 클릭하고 표시된 액세스 토큰을 복사하세요. 나중에 Python 스크립트를 구성할 때 이 토큰이 필요합니다.
## The Python Script
## 파이썬 스크립트
If you don’t know how to run this script and are just getting started with Python, check out our long list of tutorials.
이 스크립트를 실행하는 방법을 모르고 이제 막 Python을 시작하는 경우에는 긴 튜토리얼 목록을 확인하세요.
You can copy and paste the following Python script into a text file and run it to make a post on the Facebook page you have the access code for:
다음 Python 스크립트를 복사하여 텍스트 파일에 붙여넣고 실행하여 액세스 코드가 있는 Facebook 페이지에 게시물을 작성할 수 있습니다.
```python
``파이썬
# First, install the Requests if you don't already have it
# 먼저 Requests가 아직 없으면 설치합니다.
pip install requests
pip 설치 요청
# Here is the complete code:
# 전체 코드는 다음과 같습니다.
import requests
수입요청
# Replace these with your actual access token and page ID or user ID
# 이를 실제 액세스 토큰과 페이지 ID 또는 사용자 ID로 바꿉니다.
access_token = 'your_facebook_access_token'
access_token = 'your_facebook_access_token'
page_id = 'your_page_or_user_id'
page_id = 'your_page_or_user_id'
message = 'Hello, this is a test post from my Python script!'
message = '안녕하세요. 제 Python 스크립트의 테스트 게시물입니다!'
# Define the URL for posting to the Facebook Graph API
# Facebook Graph API에 게시하기 위한 URL을 정의합니다.
post_url = f'https://graph.facebook.com/v17.0/{page_id}/feed'
post_url = f'https://graph.facebook.com/v17.0/{page_id}/feed'
# Parameters to be sent with the request
# 요청과 함께 전송될 매개변수
payload = {
페이로드 = {
'message': message,
'메시지': 메시지,
'access_token': access_token
'액세스_토큰': 액세스_토큰
}
}
# Make the POST request to Facebook
# Facebook에 POST 요청을 합니다.
response = requests.post(post_url, data=payload)
응답 = 요청.포스트(post_url, 데이터=페이로드)
# Check if the post was successful
# 포스팅이 성공했는지 확인
if response.status_code == 200:
response.status_code == 200인 경우:
print('Post published successfully!')
print('글이 성공적으로 게시되었습니다!')
else:
또 다른:
print(f'Failed to post. Status code: {response.status_code}')
print(f'게시에 실패했습니다. 상태 코드: {response.status_code}')
print(f'Error: {response.text}')
print(f'오류: {response.text}')
```
````
To run this script, first change the code to include your page ID and access code where it says to do so. Then, save the file with a .py extension (e.g.,
이 스크립트를 실행하려면 먼저 페이지 ID와 액세스 코드를 포함하도록 코드를 변경하세요. 그런 다음 파일을 .py 확장자로 저장합니다(예:
부인 성명:info@kdj.com
제공된 정보는 거래 조언이 아닙니다. kdj.com은 이 기사에 제공된 정보를 기반으로 이루어진 투자에 대해 어떠한 책임도 지지 않습니다. 암호화폐는 변동성이 매우 높으므로 철저한 조사 후 신중하게 투자하는 것이 좋습니다!
본 웹사이트에 사용된 내용이 귀하의 저작권을 침해한다고 판단되는 경우, 즉시 당사(info@kdj.com)로 연락주시면 즉시 삭제하도록 하겠습니다.