定制 zebrello/feedly-api 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

zebrello/feedly-api

最新稳定版本:1.0.0

Composer 安装命令:

composer require zebrello/feedly-api

包简介

PHP library to use Feedly Cloud API

README 文档

README

Scrutinizer Code Quality

Simple PHP library to use Feedly Cloud API based on Guzzle

Requirements

Installation

Using Composer

To install feedly-api with Composer, just add by running the following command:

composer require zebrello/feedly-api

Composer installs autoloader at ./vendor/autoloader.php. to include the library in your script, add:

require_once 'vendor/autoload.php';

If you use Symfony2, autoloader has to be detected automatically.

You can see this library on Packagist.

Usage

Authenticate to your feedly cloud account

use FeedlyApi\Client;

// The sandbox client id and client secret are posted once a month on the feedly cloud forum:  https://groups.google.com/forum/#!forum/feedly-cloud.
// More info on https://developer.feedly.com/v3/sandbox/
// If using the sandbox set $sandboxMode to true | default is false

$client = new Client($clientId, $clientSecret, $redirectUri, $sandboxMode);
$loginUrl = $client->getLoginUrl();

// Redirect to the loginUrl to authenticate
header('Location: '. $loginUrl);

Handling the response

use FeedlyApi\Client;

$client = new Client($clientId, $clientSecret, $redirectUri, $sandboxMode);

// The response will be sent to the $redirectUri

if($_GET['code']){
  $client->auth($_GET['code']);

  // Get the accessToken and save it to the session
  $_SESSION['feedlyAccessToken'] = $client->getAccessToken();
}

Request example (profile)

use FeedlyApi\Client;

$client = new Client($clientId, $clientSecret, $redirectUri, $sandboxMode);

// Set the accessToken from session
$client->setAccessToken($_SESSION['feedlyAccessToken']);

$profile = $client->call('profile');

Example in Symfony get categories and rename first category to 'test'

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
use FeedlyApi\Client;
use GuzzleHttp\Exception\ClientException;

class DefaultController extends Controller
{
    /**
     * @Route("/")
     */
    public function indexAction(Request $request)
    {
        $session = $request->getSession();
        $client = new Client('sandbox', '4205DQXBAP99S8SUHXI3', $this->get('router')->generate('app_default_index', array(), true), true);
        if($request->query->has('code')){
            $client->auth($request->query->get('code'));
            $session->set('feedlyAccessToken', $client->getAccessToken());
        }

        if($session->has('feedlyAccessToken')){
            $client->setAccessToken($session->get('feedlyAccessToken'));
        }

        try {
            $categories = $client->call('categories');
            $body = array(
                'label' => 'Test',
            );
            $response = $client->call('categories', $categories[0]['id'], 'post', $body);
            return new JsonResponse($response);
        } catch (ClientException $e){
            return new JsonResponse($e->getResponse()->json());
        } catch (\Exception $e){
            $loginUrl = $client->getLoginUrl();
            return $this->redirect($loginUrl);
        }
    }
}

Contributing

See CONTRIBUTING file.

License

feedly-api is released under the MIT License. See the bundled LICENSE file for details.

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-23