使用上传API(PHP)上传到flickr

时间:2013-12-16 03:46:50

标签: php upload flickr

我正在尝试构建一个上传到定义的flickr帐户的自定义上传脚本,我正在寻找除phpflickr之外的东西(使用flickr api的弃用版本)。我知道如何在新方法中授权flickr调用并成功使用了至少六种方法,但我无法理解如何上传(主要是因为文档非常有限)。

这是我正在使用的授权电话:

<?php
$url  = "format=" . $this->format;
$url .= "&method=" . $method;
$url .= "&nojsoncallback=1";
$url .= "&oauth_consumer_key=" . $this->flickr_key;
$url .= "&oauth_nonce=" . $this->nonce;
$url .= "&oauth_signature_method=" . $this->sig_method;
$url .= "&oauth_timestamp=" . $this->timestamp;
$url .= "&oauth_token=" . $access_token;
$url .= "&oauth_version=1.0";
$url .= "&photoset_id=" . $photoset_id;

$baseurl            = "GET&" . urlencode( $flickr_upload_call ) . "&" . urlencode( $url );
$hashkey            = $this->flickr_secret . "&" . $access_token_secret;
$oauth_signature    = base64_encode( hash_hmac( 'sha1', $baseurl, $hashkey, true ));

$url_parameters = array(
    'method'                =>$method,
    'oauth_consumer_key'    =>$this->flickr_key,
    'photoset_id'           =>$photoset_id,
    'format'                =>$this->format,
    'nojsoncallback'        =>'1',
    'oauth_nonce'           =>$this->nonce,
    'oauth_timestamp'       =>$this->timestamp,
    'oauth_signature_method'=>$this->sig_method,
    'oauth_version'         =>'1.0',
    'oauth_token'           =>$access_token,
    'oauth_signature'       =>$oauth_signature
);

/* Now that we have encoded the parameters for our ouath_signature
*  and have reformated them for the url we need to send... we must
*  re-urlencode them too. */

$parameters_string = "";
foreach ( $url_parameters as $key=>$value )
    $parameters_string .= "$key=" . urlencode( $value ) . "&";

$url = $flickr_api_call . "?" . $parameters_string;

所以,我需要知道的是如何改变它以允许flickr上传api接受它;任何我可以做得更好的方法,或者我如何使用phpflickr中的内容并将其转换为适合我需要的新方法?

0 个答案:

没有答案