开发者

Posting blogger post with PHP Pecl OAuth, whithout Zend GData

My FreeBSD web-server does not support Zend Framework, so I'm trying figure it out with php's pecl oauth extension. After hours of googling and a day of implementing i recieved a list of blogs, but i cant post a new blog post. i found this Using the OAuth PHP Pecl extension to post to blogger feed and implemented like there. Here is a part of my solution:

$data = '<entry xmlns=\'http://www.w3.org/2005/Atom\'>
        <title type=\'text\'>Marriage!</title>
        <content type=\'xhtml\'>
            <div xmlns="http://www.w3.org/1999/xhtml">
            <p>Mr. Darcy has <em>proposed marriage</em> to me!</p>
            <p>He is the last man on earth I would ever desire to marry</p>
                <p>Whatever shall I do?</p>
            </div>
    </content>
        <category scheme="http://www.blogger.com/atom/ns#" term="marriage" />
        <category scheme="http://www.blogger.com/atom/ns#" term="Mr. Darcy" />
    </entry>'; 
    $params = array(
        'request_token_url' => 'https://www.google.com/accounts/OAuthGetRequestToken',
        'request_token_url_data' => array('scope' => 'http://www.blogger.com/feeds', 'oauth_callback' => $callback_url),
        'autorize_url' => 'https://www.google.com/accounts/OAuthAuthorizeToken',
        'access_token_url' => 'https://www.google.com/accounts/OAuthGetAccessToken',
        'callback_url' => $callback_url,
        'call_url' => 'http://www.blogger.com/feeds/{$blog->id}/posts/default',
        'call_url_data' => $data,
        'service' => 'google',
        'method' => OAUTH_HTTP_M开发者_运维技巧ETHOD_POST,
        'header' => array('Content-Type' => 'application/atom+xml'),

assuming that I already have OAuth token.

$oauth->setToken($_SESSION[$oauth_token],$_SESSION[$oauth_secret]);
$oauth->fetch($params['call_url'], $params['call_url_data'], $params['method'], $params['header'])
return $oauth->getLastResponse();

in response i recieve:

400 BAD REQUEST Invalid request URI or header, or unsupported nonstandard parameter

and i stuck here. maybe $data is not well formatted?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜