从Buffer API发布内容

时间:2016-01-29 13:17:42

标签: php api oauth get buffer

我已经使用了这个OAuth资源库https://github.com/thewebguy/bufferapp-php,我正试图将我的缓冲区帖子拉到我的网站。

但是,我无法理解如何正确拨打电话并显示内容。

我可以正确访问API并发布内容,但我想解决的是如何在我网站上的缓冲帖子中显示内容。

我已使用以下代码成功发布帖子:

<?
session_start();
require('buffer.php');

$client_id = 'xxxxxxxxxxxxxxxxxxxxx';
$client_secret = 'xxxxxxxxxxxxxxxxxxxxxx';
$callback_url = 'http://www.readadvisors.com';

$buffer = new BufferApp($client_id, $client_secret, $callback_url);

if (!$buffer->ok) {
    echo '<a href="' . $buffer->get_login_url() . '">Connect to Buffer!</a>';
} else {
    $profiles = $buffer->go('/profiles');

    if (is_array($profiles)) {
        foreach ($profiles as $profile) {
            //$buffer->go('/updates/create', array('text' => 'My first status update from bufferapp-php worked!', 'profile_ids[]' => $profile->id));
            $buffer->go('/profiles/:id/updates/sent');
        }
    }
}
?>

现在我希望能够将此代码用于其他API调用,如下所示:https://buffer.com/developers/api/updates

我对GET / profiles /:id / updates / sent

特别感兴趣

非常感谢你的帮助!!!

[R

1 个答案:

答案 0 :(得分:0)

您可以使用以下库:https://github.com/miguelbemartin/buffer-sdk-php

获取发送的更新非常简单:

// Create a new AuthorizationToken
$auth = new AuthorizationToken('XXX');

// Create a new Buffer Wrapper Client
$buffer = new Buffer($auth);

// Get Profiles
$profiles = $buffer->profileService->getProfiles();

foreach ($profiles as $profile) {
   $updates = $buffer->updateService->getSentUpdates($profile["id"]);
}