poster/api-php-binding 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

poster/api-php-binding

最新稳定版本:1.0.8

Composer 安装命令:

composer require poster/api-php-binding

包简介

PHP library which makes Poster API using smooth as glass

README 文档

README

PHP library which makes Poster API using smooth as glass. You can use suggestions to api methods names and don`t have to worry about request type. Just navigate through API sections like settings or menu.

Installation

composer require poster/api

Example of making API calls

It's convenient to use singleton class PosterApi. All you need to is initialize class with user credentials and then you can call Poster API methods anywhere in your project

<?php

use poster\src\PosterApi;

// Setting up account and token for requests 
PosterApi::init([
    'account_name' => 'demo',
    'access_token' => '4164553abf6a031302898da7800b59fb',
]);

// Reading settings
$result = (object)PosterApi::settings()->getAllSettings(); 
var_dump($result);

// Setting up extras for account 
$result = (object)PosterApi::application()->setEntityExtras([
    'entity_type' => 'settings',
    'extras' => [
        'synced' => true
    ]
]);
var_dump($result);

Example of OAuth

  1. Generate url and redirect user to it to start oAuth
<?php

use poster\src\PosterApi;

PosterApi::init([
    'application_id' => 1, // Your application id (client_id) 
    'application_secret' => '1362900b6c441dd0f219bd0974c7e2b8', // secret
    'redirect_uri' => 'http://example.com/poster/auth',
]);

$oAuthUrl = PosterApi::auth()->getOauthUrl();

// Redirect user to this url to start authorization
http_redirect($oAuthUrl);
  1. Catch user redirect to the redirect_uri which you used in previous step and get access token
<?php 

use poster\src\PosterApi;

$result = (object)PosterApi::auth()->getOauthToken($_GET['account'], $_GET['code']);

if (empty($result->access_token)) {
    echo "Poster auth error";
	var_dump($result);
	die;
}

// In case of successful auth, token and account name would be placed into config automatically
$settings = PosterApi::settings()->getAllSettings();
var_dump($settings);

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 10
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-07