0
只是將圖片上傳到twitpic時出現問題Twitter和TwitPic-Oauth的圖片上傳應用程序是必需的嗎?
即使我的用戶名和密碼正確,我仍然收到失敗響應。 這是因爲現在上傳圖片到twitpic(我假設推特)你必須使用Oauth?
<err code="1001" msg="Invalid twitter username or password" />
這是我使用
package
{
import flash.events.DataEvent;
import flash.events.Event;
import flash.filesystem.File;
import flash.net.FileFilter;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLVariables;
public class TwitPic
{
private var _file:File;
public function TwitPic()
{
_file = new File();
_file.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,uploadCompleteDataHandler);
browse();
}
private function browse():void {
_file.addEventListener(Event.SELECT, fileSelected);
_file.browse(new Array(new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg;*.jpeg;*.gif;*.png")));
}
private function fileSelected(event:Event):void {
var urlRequest:URLRequest = new URLRequest("http://twitpic.com/api/upload");
// The API requires the request be sent via POST
urlRequest.method = URLRequestMethod.POST;
// Enter a valid Twitter username/password combination
var urlVars:URLVariables = new URLVariables();
urlVars.username = TWITTER_USERNAME;
urlVars.password = TWITTER_PASSWORD;
urlRequest.data = urlVars;
// The API requires the file be labeled as 'media'
_file.upload(urlRequest, 'media');
}
private function uploadCompleteDataHandler(event:DataEvent):void
{
var resultXML:XML = new XML(event.text);
// Trace the path to the resulting image tiny url (mediaurl)
trace(resultXML.child("mediaurl")[0]);
}
}
}
感謝,但V1和V2使用OAuth。我的問題是Oauth是否絕對有必要上傳圖像數據。我的代碼示例中的 –
我沒有使用Oauth –