我的FreeBSD网络服务器不支持Zend Framework,所以我试图用php的pecl oauth扩展来解决它。经过几个小时的谷歌搜索和一天的实施,我收到了一个博客列表,但我不能发布一篇新的博客文章。 我找到了这个Using the OAuth PHP Pecl extension to post to blogger Feed并在那里实现了。 以下是我的解决方案的一部分:
$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_METHOD_POST,
'header' => array('Content-Type' => 'application/atom+xml'),
假设我已经拥有OAuth令牌。
$oauth->setToken($_SESSION[$oauth_token],$_SESSION[$oauth_secret]);
$oauth->fetch($params['call_url'], $params['call_url_data'], $params['method'], $params['header'])
return $oauth->getLastResponse();
作为回应我收到:
400 BAD REQUEST无效的请求URI或标头,或不受支持 非标准参数
我被困在这里。也许$ data格式不正确?