我按照http://googlemac.blogspot.com/2011/05/ios-and-mac-sign-in-controllers.html跟踪,允许用户使用Google登录iPhone应用.点击"允许访问"按钮后,我得到一个额外的屏幕,上面写着"请复制此代码,切换到您的应用程序并将其粘贴到那里:(文本框中的代码)."
这就是我所拥有的:
- (IBAction)googleLoginTapped:(UIButton *)sender
{
[self loginToGoogle];
}
- (void)loginToGoogle
{
// For Google APIs, the scope strings are available
// in the service constant header files.
NSString *scope =@"https://www.googleapis.com/auth/userinfo.profile";
// Typically, applications will hardcode the client ID and client secret
// strings into the source code; they should not be user-editable or visible.
// But for this sample code, they are editable.
NSString *clientID = @"my clientID";
NSString *clientSecret = @"my clientSecret";
// Display the …
Run Code Online (Sandbox Code Playgroud) 我们有一个网络应用程序,允许用户将文件上传到他们的Dropbox帐户.此Web应用程序使用Dropbox API来促进上载过程.上传后,当用户尝试查看文件类型.docx时,它会显示一条消息,"文件"somefile.docx"无法打开,因为内容存在问题".
以下是我们使用的一些代码:
首先,我们将文件转换为byte []并将其传递给API方法调用.
public static string DropboxUpload(byte[] DBbyte, string filename, string token, string tokensecret)
{
try
{
for (int i = 0; i < 4; i++)
{
var dropclient = new RestClient(FILEURL);
dropclient.ClearHandlers();
dropclient.AddHandler("*", new JsonDeserializer());
dropclient.BaseUrl = FILEURL;
dropclient.Authenticator = new OAuthAuthenticator(dropclient.BaseUrl, API_KEY, API_SECRET, token, tokensecret);
var request = new RestRequest(Method.POST);
request.Resource = VERSION + "/files/dropbox" + PATH;
request.AddParameter("file", filename);
request.AddFile(new FileParameter { Data = DBbyte, FileName = filename, ParameterName = "file" });
var response = dropclient.Execute(request); …
Run Code Online (Sandbox Code Playgroud)