public string UploadImage(OAuth credential, string path, string comment)
        {
            this.lastCredential = credential;
            this.lastPath = path;
            this.lastComment = comment;

            if (!initializedInjection)
                InitializeInjection();

            return string.Empty;//何もしない
        }
Пример #2
0
 public string UploadImage(OAuth credential, string path, string comment)
 {
     string url;
     if (!credential.UploadToTwitpic(_appk, comment, path, out url))
     {
         return null;
     }
     else
     {
         return url;
     }
 }
Пример #3
0
 public string UploadImage(OAuth credential, string path, string comment)
 {
     throw new NotImplementedException();
 }
Пример #4
0
 public TwitterStatus PostAndUpload(OAuth credential, string path, string body, long? inReplyTo)
 {
     return credential.UpdateWithMedia(body, path, inReplyTo);
 }
Пример #5
0
 //commentは捨てる - APIにない
 public string UploadImage(OAuth credential, string path, string comment)
 {
     string url;
     YfrogApi.UploadToYfrog(credential, _appk, path, out url);
     return url;
 }
        //できるだけ遅くUpdateInjectionに登録する
        private void InitializeInjection()
        {
            //UpdateInjectionを支配して画像投稿させる
            PostOffice.UpdateInjection.Injection(
                (arg, next, last) =>
                {
                    if (lastComment == null || arg.Item2.Trim() != lastComment)
                        return next.Invoke(arg);

                    var req = Http.CreateRequest(
                        new Uri(ApiUrl),
                        "POST",
                        "multipart/form-data");

                    //タイムアウト時間を2倍に
                    req.Timeout *= 2;

                    //リフレクションでGetHeaderを呼び出す
                    var reg = (string)typeof(OAuth).InvokeMember(
                        "GetHeader",
                        BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance,
                        null,
                        this.lastCredential,
                        new object[] { ApiUrl, CredentialProvider.RequestMethod.POST, null, null, false });

                    req.Headers.Add("Authorization", "OAuth " + reg);

                    var data = new List<SendData>();
                    data.Add(new SendData("status", text: this.lastComment));
                    data.Add(new SendData("media[]", file: this.lastPath));

                    if (arg.Item3.HasValue)
                        data.Add(new SendData("in_reply_to_status_id", text: arg.Item3.Value.ToString()));

                    //投稿
                    var res = Http.WebUpload(req, data, Encoding.UTF8, s =>
                        TwitterStatus.FromNode(XElement.Load(JsonReaderWriterFactory.CreateJsonReader(s, XmlDictionaryReaderQuotas.Max))));

                    if (res.ThrownException != null)
                        throw res.ThrownException;

                    TweetStorage.Register(res.Data);
                    NotifyStorage.Notify("ツイートしました:@" + arg.Item1.ScreenName + ": " + res.Data.Text);

                    this.lastCredential = null;
                    this.lastComment = null;
                    this.lastPath = null;

                    var chunk = PostOffice.GetUnderControlChunk(arg.Item1);
                    if (chunk.Item2 > TwitterDefine.UnderControlWarningThreshold)
                    {
                        throw new TweetAnnotationException(TweetAnnotationException.AnnotationKind.NearUnderControl);
                    }
                    return chunk.Item2;
                },
                InjectionMode.InjectionLast
            );

            this.initializedInjection = true;
        }