Commits

Matt Hamilton committed 13c48b2

Fixed media upload

  • Participants
  • Parent commits 6d02474
  • Branches httpclient

Comments (0)

Files changed (4)

File Budgie.Playground/Budgie.Playground.csproj

     <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     <TargetFrameworkProfile>Client</TargetFrameworkProfile>
     <FileAlignment>512</FileAlignment>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
     <PlatformTarget>x86</PlatformTarget>
     <Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
     <Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
   </Target>
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">

File Budgie.Playground/Program.cs

 
             Authenticate(client);
 
+            var media = System.IO.File.ReadAllBytes(@"D:\Projects\Budgie\Images\budgie-256.png");
+            //var r = client.PostAsync("Testing image upload with Budgie and HttpClient!", new[] { media }).Result;
+            var r = client.PostAsync("And testing a tweet with no media to make sure that's not broken. :|").Result;
+
+            Console.WriteLine(r.StatusCode + "\t" + r.ErrorMessage);
             //TestAuthentication(client);
-            TestHomeTimeline(client);
+            //TestHomeTimeline(client);
             // TestFavorites(client);
             // TestSavedSearches(client);
             // TestLists(client);

File Budgie/TwitterClient.OAuth.cs

                 }
             }
 
-            if (request.Content != null)
+            var body = request.Content as StringContent;
+            if (body != null)
             {
-                var content = await request.Content.ReadAsStringAsync();
+                var content = await body.ReadAsStringAsync();
                 foreach (var p in content.Split('&'))
                 {
                     var kv = p.Split('=');

File Budgie/TwitterClient.Tweets.cs

             var relativeUri = "statuses/update_with_media.json";
 
             var request = new HttpRequestMessage(HttpMethod.Post, relativeUri);
+            request.Properties["tokens"] = _accessToken;
 
             var body = new MultipartFormDataContent("=============" + DateTime.Now.Ticks.ToString("x"));
             body.Add(new StringContent(text), "status");