> ## Documentation Index
> Fetch the complete documentation index at: https://generaltranslation.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 좋아요 관리

<div id="manage-likes-standard-v11-compared-to-x-api-v2">
  ### 좋아요 관리: Standard v1.1와 X API v2 비교
</div>

Standard v1.1의 [POST favorites/create](https://developer.x.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-favorites-create) 및 [POST favorites/destroy](https://developer.x.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-favorites-destroy) 엔드포인트를 사용해 왔다면, 이 가이드의 목적은 Standard v1.1과 X API v2의 좋아요 관리 엔드포인트 간 공통점과 차이점을 이해하는 데 도움을 주는 것입니다.

* **유사점**
  * OAuth 1.0a 사용자 컨텍스트
* **차이점**
  * 엔드포인트 URL 및 HTTP 메서드
  * App 및 Project 요구 사항
  * 요청 매개변수

<div id="similarities">
  #### 유사점
</div>

**OAuth 1.0a 사용자 컨텍스트 인증 방식**

엔드포인트의 두 버전 모두 [OAuth 1.0a User Context](/ko/resources/fundamentals/authentication#oauth-1-0a-2)를 지원합니다. 따라서 이전에 표준 v1.1 좋아요 관리 엔드포인트 중 하나를 사용하고 있었다면, X API v2 버전으로 마이그레이션하더라도 동일한 인증 방식을 계속 사용할 수 있습니다.

<div id="differences">
  #### 차이점
</div>

**엔드포인트 URL 및 HTTP 메서드**

* Standard v1.1 엔드포인트:
  * POST [https://api.x.com/1.1/favorites/create.json](https://api.x.com/1.1/favorites/create.json)
    (게시물 좋아요)
  * POST [https://api.x.com/1.1/favorites/destroy.json](https://api.x.com/1.1/favorites/destroy.json)
    (게시물 좋아요 취소)
* X API v2 엔드포인트:
  * POST [https://api.x.com/2/tweets/:id/likes](https://api.x.com/2/tweets/:id/likes)
    (게시물 좋아요)
  * DELETE [https://api.x.com/2/tweets/:id/likes/:tweet\&#95;id](https://api.x.com/2/tweets/:id/likes/:tweet\&#95;id)
    (게시물 좋아요 취소) 

**App 및 Project 요구 사항**

X API v2 엔드포인트를 사용할 때는 요청을 인증할 때 [developer App](/ko/resources/fundamentals/developer-apps)이 [Project](/ko/resources/fundamentals/developer-apps)와 연결되어 있어야 하며, 해당 App의 자격 증명을 사용해야 합니다. 모든 X API v1.1 엔드포인트는 Project에 연결되지 않은 단독 App이든 Project와 연결된 App이든 모두 그 자격 증명을 사용할 수 있습니다.

**요청 매개변수**

다음 Standard v1.1 요청 매개변수는 X API v2에서 다음과 같이 매핑됩니다.

| Standard v1.1      | X API v2 |
| :----------------- | :------- |
| id                 | id       |
| includes\_entities | 해당 없음    |

Standard v1.1 매개변수는 쿼리 매개변수로 전달되는 반면, X API v2 매개변수는 POST 엔드포인트의 경우 본문 매개변수로, DELETE 엔드포인트의 경우 경로 매개변수로 전달된다는 점에 유의하세요.

또한, Standard v1.1 엔드포인트를 사용할 때는 게시물에 좋아요를 누르는 사용자의 id가 필요하지 않습니다. 함께 전달되는 [Access Tokens](/ko/resources/fundamentals/authentication#obtaining-access-tokens-using-3-legged-oauth-flow)와 [OAuth 1.0a User Context](/ko/resources/fundamentals/authentication)를 통해 어떤 사용자가 좋아요/좋아요 취소를 수행하는지 유추하기 때문입니다.

***

<div id="code-examples">
  ## 코드 예제
</div>

<div id="like-a-post-v2">
  ### 게시물에 좋아요 표시하기 (v2)
</div>

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl -X POST "https://api.x.com/2/users/123456789/likes" \
    -H "Authorization: OAuth ..." \
    -H "Content-Type: application/json" \
    -d '{"tweet_id": "1234567890"}'
  ```

  ```python Python theme={null}
  # OAuth 1.0a 사용자 컨텍스트(User Context) 인증이 필요합니다
  import requests
  from requests_oauthlib import OAuth1

  auth = OAuth1(
      "API_KEY", "API_SECRET",
      "ACCESS_TOKEN", "ACCESS_TOKEN_SECRET"
  )

  url = "https://api.x.com/2/users/123456789/likes"
  response = requests.post(url, auth=auth, json={"tweet_id": "1234567890"})
  print(response.json())
  ```

  ```python Python SDK theme={null}
  from xdk import Client
  from xdk.oauth1_auth import OAuth1

  oauth1 = OAuth1(
      api_key="YOUR_API_KEY",
      api_secret="YOUR_API_SECRET",
      access_token="YOUR_ACCESS_TOKEN",
      access_token_secret="YOUR_ACCESS_TOKEN_SECRET"
  )

  client = Client(auth=oauth1)

  # 게시물에 좋아요 표시
  response = client.posts.like(user_id="123456789", tweet_id="1234567890")
  print(f"Liked: {response.data.liked}")
  ```

  ```javascript JavaScript SDK theme={null}
  import { Client, OAuth1 } from "@xdevplatform/xdk";

  const oauth1 = new OAuth1({
    apiKey: "YOUR_API_KEY",
    apiSecret: "YOUR_API_SECRET",
    accessToken: "YOUR_ACCESS_TOKEN",
    accessTokenSecret: "YOUR_ACCESS_TOKEN_SECRET",
  });

  const client = new Client({ oauth1 });

  // 게시물에 좋아요 표시
  const response = await client.posts.like("123456789", { tweetId: "1234567890" });
  console.log(`Liked: ${response.data?.liked}`);
  ```
</CodeGroup>

<div id="unlike-a-post-v2">
  ### 게시물 좋아요 취소 (v2)
</div>

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl -X DELETE "https://api.x.com/2/users/123456789/likes/1234567890" \
    -H "Authorization: OAuth ..."
  ```

  ```python Python theme={null}
  # OAuth 1.0a 사용자 컨텍스트 인증이 필요합니다.
  import requests
  from requests_oauthlib import OAuth1

  auth = OAuth1(
      "API_KEY", "API_SECRET",
      "ACCESS_TOKEN", "ACCESS_TOKEN_SECRET"
  )

  url = "https://api.x.com/2/users/123456789/likes/1234567890"
  response = requests.delete(url, auth=auth)
  print(response.json())
  ```

  ```python Python SDK theme={null}
  from xdk import Client
  from xdk.oauth1_auth import OAuth1

  oauth1 = OAuth1(
      api_key="YOUR_API_KEY",
      api_secret="YOUR_API_SECRET",
      access_token="YOUR_ACCESS_TOKEN",
      access_token_secret="YOUR_ACCESS_TOKEN_SECRET"
  )

  client = Client(auth=oauth1)

  # 게시물 좋아요 취소
  response = client.posts.unlike(user_id="123456789", tweet_id="1234567890")
  print(f"Liked: {response.data.liked}")
  ```

  ```javascript JavaScript SDK theme={null}
  import { Client, OAuth1 } from "@xdevplatform/xdk";

  const oauth1 = new OAuth1({
    apiKey: "YOUR_API_KEY",
    apiSecret: "YOUR_API_SECRET",
    accessToken: "YOUR_ACCESS_TOKEN",
    accessTokenSecret: "YOUR_ACCESS_TOKEN_SECRET",
  });

  const client = new Client({ oauth1 });

  // 게시물 좋아요 취소
  const response = await client.posts.unlike("123456789", "1234567890");
  console.log(`Liked: ${response.data?.liked}`);
  ```
</CodeGroup>
