패키지, 저장소 및 앱 카테고리 검색

패키지 상세v5.0.2

wp_json_api

Flutter 모바일용 워드프레스 및 위즈커머스 JSON API. API를 사용하면 로그인, 새 사용자 등록, 사용자 정보 조회 등이 가능합니다.

AndroidiOSmacOS
30일 다운로드
515
좋아요
44
Pub 점수
160

패키지 설치

flutter pub add wp_json_api

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

wp_json_api 패키지는 Flutter 호환 인터페이스를 제공하여 WordPress 및 WooCommerce의 JSON REST API와 상호 작용할 수 있게 해줍니다. 사용자는 로그인 및 회원가입과 같은 인증 작업을 수행하고, 사용자 정보를 가져오며, WordPress 기반 사이트의 데이터를 관리할 수 있습니다. 모바일 애플리케이션을 위해 설계되었으며 Android, iOS, macOS 플랫폼을 지원합니다. 헤드리스 WordPress 설정과의 통합을 간소화하여 전자상거래 및 콘텐츠 중심 앱에 적합합니다. Woosignal에서 유지보수되며 pub.dev를 통해 이용 가능합니다.

사용 사례

  • 모바일 앱 사용자 인증
  • WooCommerce 제품 및 주문 검색
  • Flutter 앱에서 사용자 프로필 관리
  • 헤드리스 워드프레스 콘텐츠 표시
  • 전자상거래 앱과 WooCommerce 통합

주요 기능

  • 내장된 로그인 및 등록
  • WordPress 및 WooCommerce API를 지원합니다
  • 크로스 플랫폼(안드로이드, 아이오스, 맥OS)
  • 사용자 데이터 액세스를 위한 간단한 API
  • 오픈소스이며 적극적으로 유지 관리되고 있습니다

적합한 대상

  • Flutter 개발자가 WordPress 기반 앱을 구축하고 있습니다
  • WooCommerce를 사용하는 전자상거래 앱
  • 사용자 계정 관리를 필요로 하는 앱
  • 헤드리스 워드프레스를 사용하는 프로젝트
  • RESTful WordPress API와 통합하는 개발자

고려 사항

  • REST API가 활성화된 WordPress 사이트가 필요합니다
  • 인증 토큰은 안전하게 처리되어야 합니다
  • WordPress/WooCommerce 생태계에 제한됨
  • 외부 서버 구성에 따라 다릅니다
  • 네트워크 문제에 대한 추가적인 오류 처리가 필요할 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

WordPress and WooCommerce JSON API Dart package for Flutter

You can download the WordPress plugin here WP JSON API.

Install the WordPress plugin to use this Flutter package.

API features:

WordPress

  • Register/Sign Up API for Users
  • Login (with email or username)
  • Get Users Info
  • Update Users Info
  • Update Users Password
  • Add role to a user
  • Remove role from a user
  • Delete a user

WooCommerce

  • Get Customers Info (Billing and Shipping)
  • Update Customers details

To use this API you must have the WP JSON API Plugin installed first on your WordPress site, you can download it via the WooSignal website.

Getting Started

In your flutter project add the dependency:

dependencies:
  ...
  wp_json_api: ^4.3.8
Usage example

Import wp_json_api.dart

import 'package:wp_json_api/wp_json_api.dart';
Example using Wp JSON API
import 'package:wp_json_api/wp_json_api.dart';
...

void main() {

WPJsonAPI.instance.init(baseUrl: "https://mysite.com");

...
Call a method from the request callback
try {
WPUserLoginResponse wpUserLoginResponse = await WPJsonAPI.instance
          .api((request) => request.wpLogin(
            email: email,
            password: password
          ));
} on Exception catch (e) {
    print(e);
}
Available API Requests
WordPress - Get Nonce
  • Used for returning a valid nonce
WPNonceResponse wpNonceResponse = await WPJsonAPI.instance
          .api((request) => request.wpNonce());
WordPress - Verify Nonce
  • Used for verifying register and login request
WPNonceVerifiedResponse wpNonceVerifiedResponse = await WPJsonAPI.instance
          .api((request) => request.wpNonceVerify(
            nonce: nonce
          ));
WordPress - Login with email
  • Used to login a user
WPUserLoginResponse wpUserLoginResponse = await WPJsonAPI.instance
      .api((request) => request.wpLogin(
          email: email,
          password: password,
          authType: WPAuthType.WpEmail
      ));
WordPress - Login with username
  • Used to login a user
WPUserLoginResponse wpUserLoginResponse = await WPJsonAPI.instance
      .api((request) => request.wpLogin(
          username: username,
          password: password,
          authType: WPAuthType.WpUsername
      ));
WordPress - Register
  • Used to register a user
  • The username parameter is required, ensure that this is unique
WPUserRegisterResponse wpUserRegisterResponse = await WPJsonAPI.instance
      .api((request) => request.wpRegister(
          email: email,
          password: password,
          // username: username // optional - the library will automatically generate a username if not provided
      ));
WordPress - Get Users Info
  • Used to get a WordPress users info
  • After you login/register, you can all this method to get the users info
WPUserInfoResponse wpUserInfoResponse = await WPJsonAPI.instance
        .api((request) => request.wpGetUserInfo());
WordPress - Update Users Info
  • Used to update a WordPress users info
  • After you login/register, you can all this method to update the users info
WPUserInfoUpdatedResponse wpUserInfoUpdatedResponse = await WPJsonAPI.instance
        .api((request) => request.wpUpdateUserInfo(
          firstName: firstName,
          lastName: lastName,
          displayName: displayName
      ));
WordPress - Update users password
  • Used to update a users password
  • After you login/register, you can all this method to update the users password
WPUserResetPasswordResponse wpUserResetPasswordResponse = await WPJsonAPI.instance
        .api((request) => request.wpResetPassword(
            password: password
        ));
WordPress - Add a role to a user
  • Used to add a role to a user in WordPress
  • After you login/register, you can all this method to add a role to the user
WPUserAddRoleResponse wpUserAddRoleResponse = await WPJsonAPI.instance
        .api((request) => request.wpUserAddRole(
            role: "customer" // e.g. customer, subscriber
        ));
WordPress - Remove a role from a user
  • Used to remove a role from a user in WordPress
  • After you login/register, you can all this method to remove a role from the user
WPUserRemoveRoleResponse wpUserRemoveRoleResponse = await WPJsonAPI.instance
        .api((request) => request.wpUserRemoveRole(
            role: "customer" // e.g. customer, subscriber
        ));
WordPress - Delete a user
  • Used to delete a user in WordPress
  • After you login/register, you can all this method to delete the user
  • You can pass an optional argument 'reassign' to reassign posts and links to new User ID.
WPUserDeleteResponse wpUserDeleteResponse = await WPJsonAPI.instance
        .api((request) => request.wpUserDelete());
WooCommerce - Register
  • Used to register a user
WPUserRegisterResponse wpUserRegisterResponse = await WPJsonAPI.instance
      .api((request) => request.wpRegister(
          email: email,
          password: password
      ));
WooCommerce - Get users info in WooCommerce
  • Used to get WooCommerce info for a given user
  • After you login/register, you can all this method to get the users WooCommerce info
WCCustomerInfoResponse wcCustomerInfoResponse = await WPJsonAPI.instance
          .api((request) => request.wcCustomerInfo(
          userToken
      ));
WooCommerce - Update users info in WooCommerce
  • Used to update a users WooCommerce details
  • All the parameter are optional so if you wanted to just update the name, you could just add first_name and last_name
  • After you login/register, you can all this method to update the users WooCommerce info
WCCustomerUpdatedResponse wcCustomerUpdatedResponse = await WPJsonAPI.instance
        .api((request) => request.wcUpdateCustomerInfo(
            firstName: firstName,
            lastName: lastName,
            displayName: displayName,
            billingFirstName: billingFirstName,
            billingLastName: billingLastName,
            billingCompany: billingCompany,
            billingAddress1: billingAddress1,
            billingAddress2: billingAddress2,
            billingCity: billingCity,
            billingState: billingState,
            billingPostcode: billingPostcode,
            billingCountry: billingCountry,
            billingEmail: billingEmail,
            billingPhone: billingPhone,
            shippingFirstName: shippingFirstName,
            shippingLastName: shippingLastName,
            shippingCompany: shippingCompany,
            shippingAddress1: shippingAddress1,
            shippingAddress2: shippingAddress2,
            shippingCity: shippingCity,
            shippingState: shippingState,
            shippingPostcode: shippingPostcode,
            shippingCountry: shippingCountry,
            shippingEmail: shippingEmail,
            shippingPhone: shippingPhone
        ));
WooCommerce Points and Rewards - Get user's points
  • This is used to get the user's current points in the WooCommerce Points and Rewards plugin
  • After you login/register, you can all this method to get the users points
WcPointsAndRewardUser wcPointsAndRewardUser = await WPJsonAPI.instance
          .api((request) => request.wcPointsAndRewardsUser());
WooCommerce Points and Rewards - Calculate the value of points
  • This is used to calculate the value of points in the WooCommerce Points and Rewards plugin
  • After you login/register, you can all this method to calculate the value of points
WcPointsAndRewardCalculatePoints wcPointsAndRewardsCalculatePoints = await WPJsonAPI.instance
          .api((request) => request.wcPointsAndRewardsCalculatePoints(
          points: 100
      ));

For help getting started with WooSignal, view our online documentation, which offers a more detailed guide.

Usage

To use this plugin, add wp_json_api as a dependency in your pubspec.yaml file.

Note

Install our WordPress plugin "WP JSON API" v3.4.0 to use this flutter plugin.

Disclaimer: This plugin is not affiliated with or supported by Automattic, Inc. All logos and trademarks are the property of their respective owners.

카테고리

의존성

의존성 목록 4 개

소스 저장소

이 패키지를 사용하는 프로젝트