从缓冲区 API 发布内容


Posting content from Buffer API

我已经使用了这个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

您可以使用此库: 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"]);
}