Tag: api

访问令牌Google+

我在使用新发布的Google+ API检索访问令牌时遇到了一些问题… 我一直在关注文档 ,我得到了一个代码(“4 / blablabla”)但是当我发送POST请求以获取访问令牌时,我得到一个“(400)错误请求”响应… 这是我的一段代码: // We have a request code, now we want an access token StringBuilder authLink = new StringBuilder(); authLink.Append(“https://accounts.google.com/o/oauth2/token”); authLink.AppendFormat(“?code={0}”, gplusCode); authLink.AppendFormat(“&client_id={0}”, myClientId); authLink.AppendFormat(“&client_secret={0}”, mySecret); authLink.AppendFormat(“&redirect_uri={0}”, myRedirectUri); authLink.Append(“&scope=https://www.googleapis.com/auth/plus.me”); authLink.Append(“&grant_type=authorization_code”); OAuthBase oAuth = new OAuthBase(); string normalizedUrl, normalizedRequestParameters; string oAuthSignature = oAuth.GenerateSignature(new Uri(authLink.ToString()), appKey, appSecret, code, null, HttpMethod.POST.ToString(), oAuth.GenerateTimeStamp(), oAuth.GenerateNonce(), […]

如何在.NET中调用DrawThemeTextEx

我需要在Vista / 7玻璃窗口中写一个带有发光的文本,我试图调用API在那里写一些文本。 我在CodeProject中检查了一个很好的示例 ,但问题是我使用的是.NET 1(请不要问:-) 我需要将以下.NET 2代码转换为PInvoke,.NET 1代码。 // using System.Windows.Forms.VisualStyles VisualStyleRenderer renderer = new VisualStyleRenderer( VisualStyleElement.Window.Caption.Active); // call to UxTheme.dll DrawThemeTextEx(renderer.Handle, memoryHdc, 0, 0, text, -1, (int)flags, ref textBounds, ref dttOpts); .NET 1中不存在VisualStyleRenderer类,因此我需要以其他方式获取renderer.Handle 。

用于检索xml数据的C#代码

基于此源代码,我无法将API中的数据检索到XDocument 。 我检索错误消息 {“远程服务器返回错误:(400)错误请求。”} 题: 我不知道该怎么办? XDocument xml = XDocument.Parse(new WebClient().DownloadString(“http://api.arbetsformedlingen.se/af/v0/platsannonser/matchning?lanid=1&kommunid=180&yrkesid=2419&1&antalrader=10000”));

如何使用C#发布到WordPress?

我想编写一个程序,可以使用C#通过POST方法将数据发布到WordPress中。 我不知道那样做。 我希望有人帮助我一些想法。 WordPress有任何API支持吗? 谢谢 !

使用公共/实用程序库

在我工作的公司,我们有一个“实用程序”项目,我们构建的应用程序几乎引用了它。 它有很多东西,比如NullHelpers,ConfigSettingHelpers,Common ExtensionMethods等。 我们的工作方式是,当我们想要创建一个新项目时,我们从源代码控制中获取最新版本的项目,将其添加到解决方案中,然后从添加到解决方案中的任何新项目中引用项目。 这已经运作正常,但是有一些情况下,人们对共同项目进行了“重大改变”,这对他们有用,但对其他项目不起作用。 我一直在考虑,不是将公共库添加为项目参考,我们应该开始将公共库作为独立的dll开发并发布不同的版本并针对特定项目定位特定版本,以便可以在没有任何风险的情况下进行更改使用公共库的其他项目。 说了所有我有兴趣看到别人如何引用或使用他们的公共库。

将OAuth 2与桌面c#应用程序一起使用

我之前从未使用oauth,所以我希望我的应用程序在系统的默认浏览器上打开一个URL,然后用户登录,授权等等,然后我需要将授权代码发送回我的应用程序,有没有办法做它? 我正在使用Trakt的API 。

创建防火墙规则以c#编程方式打开每个应用程序的端口

我需要为我的应用程序打开特定端口。 我已尝试为每个端口使用每个应用程序的INetFwAuthorizedApplication规则。 fwMgr.LocalPolicy.CurrentProfile.AuthorizedApplications.Add(app) 或者,使用INetFwOpenPort为所有应用程序打开一个端口。 firewallManager.LocalPolicy.CurrentProfile.GloballyOpenPorts.Add(port) 有没有办法以编程方式以编程方式为每个应用程序打开单个端口? 我可以通过防火墙设置手动完成。

Google通讯录API – 获取访问令牌(oauth)后

我设法为谷歌的联系人API获取访问令牌,但当我尝试拨打电话以检索登录用户的个人资料时,我收到401未经授权的错误… 我做了一些研究,并按照“各种”谷歌文档中提到的步骤(像这一个 , 这一个和许多其他),但没有用… 到目前为止,我认为我正在签署错误的请求。 这是我获得访问令牌后正在做的事情。 string outUrl,querystring; string sig = oAuth.GenerateSignature(new Uri(“https://www.google.com/m8/feeds/contacts/default/full”), Server.UrlEncode(oAuth.ConsumerKey), oAuth.ConsumerSecret, oAuth.Token, null, “GET”, timeStamp, nonce, out outUrl, out querystring); string reqURL = “https://www.google.com/m8/feeds/contacts/default/full?access_token=” + oAuth.Token + “&oauth_signature_method=HMAC-SHA1&oauth_signature=” + Server.UrlEncode(sig) + “&oauth_consumer_key=” + oAuth.ConsumerKey + “&oauth_timestamp=” + timeStamp + “&oauth_nonce=” + nonce + “&oauth_version=1.0”; response = oAuth.WebRequest(oAuthGoogle.Method.GET, reqURL, String.Empty); 使用oAuth.WebRequest()发送请求时出现401错误(上面代码的最后一行) 我只需要摆脱401错误……我正在使用ASP.NET […]

使用C#.net中的私有存储库的身份validation读取BitBucket API

我已经尝试了几天让BitBucket API为我工作,但是当它使用于具有身份validation的私有存储库(将问题设置为私有,当他们发现时)已经停止了’设置为公开,不需要身份validation,一切正常) 代码示例如下: static void Main(string[] args) { WebProxy prox = new WebProxy(“ProxyGoesHere”); prox.Credentials = CredentialCache.DefaultNetworkCredentials; var address = “repositories/UserFoo/SlugBar/issues/1”; var repCred = new CredentialCache(); repCred.Add(new Uri(“https://api.bitbucket.org/”), “Basic”, new NetworkCredential(“UserFoo”, “PassBar”)); WebClient client = new WebClient(); client.Credentials = repCred; client.Proxy = prox; client.BaseAddress = “https://api.bitbucket.org/1.0/”; client.UseDefaultCredentials = false; client.QueryString.Add(“format”, “xml”); Console.WriteLine(client.DownloadString(address)); Console.ReadLine(); } 非常感谢。

是否有低级网络库来嗅探和更改网络流量?

我正在寻找一种方法来嗅探网络数据包并使用C#对其进行编码(总结:改变网络流量)。 我不知道如何解释我的请求,但我需要像“键盘钩”这样的东西。 .net或Windows API中是否有任何库或软件?