Browse files

Create gh-pages branch via GitHub

  • Loading branch information...
1 parent d3099ab commit 7ef5b8c661f38e5d0d496a1403dac6a18c16a394 @kylebrowning committed Dec 19, 2013
Showing with 86 additions and 11 deletions.
  1. +85 −10 index.html
  2. +1 −1 params.json
View
95 index.html
@@ -41,17 +41,20 @@
<h1>
<a name="drupal-ios-sdk---connect-your-iosos-x-app-to-drupal" class="anchor" href="#drupal-ios-sdk---connect-your-iosos-x-app-to-drupal"><span class="octicon octicon-link"></span></a>Drupal iOS SDK - Connect your iOS/OS X app to Drupal</h1>
+<h5>
+<a name="originally-sponsored-by-httpworkhabitcom-built-by-kyle-browning" class="anchor" href="#originally-sponsored-by-httpworkhabitcom-built-by-kyle-browning"><span class="octicon octicon-link"></span></a>Originally Sponsored by <a href="http://workhabit.com">http://workhabit.com</a> built by <a href="http://kylebrowning.com">Kyle Browning</a>
+</h5>
+
<h1>
<a name="what-you-need-to-know" class="anchor" href="#what-you-need-to-know"><span class="octicon octicon-link"></span></a>What you need to know</h1>
<p>The Drupal iOS SDK is a standard set of libraries for communicating to Drupal from any iOS device. Its extremely simple.
-If you wanted to get a node you can do so by instantiating a DIOSNode Object, creating an
-NSDictionairy and running the nodeGet method. Heres an example:</p>
+If you wanted to get a node you can do so calling some class methods on DIOSNode, creating an
+NSDictionary and running the nodeGet method. Heres an example:</p>
-<div class="highlight highlight-obj-c"><pre> <span class="n">DIOSNode</span> <span class="o">*</span><span class="n">node</span> <span class="o">=</span> <span class="p">[[</span><span class="n">DIOSNode</span> <span class="n">alloc</span><span class="p">]</span> <span class="n">init</span><span class="p">];</span>
- <span class="n">NSMutableDictionary</span> <span class="o">*</span><span class="n">nodeData</span> <span class="o">=</span> <span class="p">[</span><span class="n">NSMutableDictionary</span> <span class="n">new</span><span class="p">];</span>
+<div class="highlight highlight-obj-c"><pre> <span class="n">NSMutableDictionary</span> <span class="o">*</span><span class="n">nodeData</span> <span class="o">=</span> <span class="p">[</span><span class="n">NSMutableDictionary</span> <span class="n">new</span><span class="p">];</span>
<span class="p">[</span><span class="n">nodeData</span> <span class="n">setValue</span><span class="o">:</span><span class="s">@"12"</span> <span class="n">forKey</span><span class="o">:</span><span class="s">@"nid"</span><span class="p">];</span>
- <span class="p">[</span><span class="n">node</span> <span class="n">nodeGet</span><span class="o">:</span><span class="n">nodeData</span> <span class="n">success</span><span class="o">:^</span><span class="p">(</span><span class="n">AFHTTPRequestOperation</span> <span class="o">*</span><span class="n">operation</span><span class="p">,</span> <span class="kt">id</span> <span class="n">responseObject</span><span class="p">)</span> <span class="p">{</span>
+ <span class="p">[</span><span class="n">DIOSNode</span> <span class="n">nodeGet</span><span class="o">:</span><span class="n">nodeData</span> <span class="n">success</span><span class="o">:^</span><span class="p">(</span><span class="n">AFHTTPRequestOperation</span> <span class="o">*</span><span class="n">operation</span><span class="p">,</span> <span class="kt">id</span> <span class="n">responseObject</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">//Do Something with the responseObject</span>
<span class="n">NSLog</span><span class="p">(</span><span class="s">@"%@"</span><span class="p">,</span> <span class="n">responseObject</span><span class="p">);</span>
<span class="p">}</span> <span class="n">failure</span><span class="o">:^</span><span class="p">(</span><span class="n">AFHTTPRequestOperation</span> <span class="o">*</span><span class="n">operation</span><span class="p">,</span> <span class="n">NSError</span> <span class="o">*</span><span class="n">error</span><span class="p">)</span> <span class="p">{</span>
@@ -61,7 +64,7 @@
</pre></div>
-<p>For every DIOS Object you make, any method calls that are available to you use blocks.
+<p>For every DIOS call you make, any method calls that are available to you use blocks.
This allows us to define what happens when we have a request that fails or succeeds.
If the request was successful the result would be something like this:</p>
@@ -82,8 +85,13 @@
</li>
<li>Be sure to follow the AFNetworking installation guide.</li>
<li>Update Settings.h with the correct correct url and endpoints)</li>
-<li><a href="http://github.com/kylebrowning/services">Services</a></li>
-</ul><h2>
+<li><a href="http://drupal.org/project/services">Services</a></li>
+</ul><h1>
+<a name="extras" class="anchor" href="#extras"><span class="octicon octicon-link"></span></a>Extras</h1>
+
+<p><a href="https://github.com/utneon/drupal-ios-sdk-addons">Drupal iOS SDK Addons</a></p>
+
+<h2>
<a name="demo-app-work-in-progress" class="anchor" href="#demo-app-work-in-progress"><span class="octicon octicon-link"></span></a>Demo App (Work in progress)</h2>
<p><a href="http://github.com/workhabitinc/drupal-ios-sdk-example">http://github.com/workhabitinc/drupal-ios-sdk-example</a></p>
@@ -104,7 +112,74 @@
<h2>
<a name="oauth" class="anchor" href="#oauth"><span class="octicon octicon-link"></span></a>OAuth</h2>
-<p>its coming.</p>
+<p>If you want to use oAuth theres only one thing you need to do for 2-legged</p>
+
+<div class="highlight highlight-obj-c"><pre> <span class="p">[</span><span class="n">DIOSSession</span> <span class="n">sharedOauthSessionWithURL</span><span class="o">:</span><span class="s">@"http://d7.workhabit.com"</span> <span class="n">consumerKey</span><span class="o">:</span><span class="s">@"yTkyapFEPAdjkW7G2euvJHhmmsURaYJP"</span> <span class="n">secret</span><span class="o">:</span><span class="s">@"ZzJymFtvgCbXwFeEhivtF67M5Pcj4NwJ"</span><span class="p">];</span>
+</pre></div>
+
+<p>This will create your shared session with the baseURL and attach your consumer key and secret.</p>
+
+<p>3-legged requires that you get some request tokens, and convert them into access tokens.
+DIOS provides methods to do this, as an Example, this code will grab some request tokens and load a webview to be displayed</p>
+
+<div class="highlight highlight-obj-c"><pre> <span class="p">[</span><span class="n">DIOSSession</span> <span class="n">getRequestTokensWithSuccess</span><span class="o">:^</span><span class="p">(</span><span class="n">AFHTTPRequestOperation</span> <span class="o">*</span><span class="n">operation</span><span class="p">,</span> <span class="kt">id</span> <span class="n">responseObject</span><span class="p">)</span> <span class="p">{</span>
+ <span class="n">requestTokens</span> <span class="o">=</span> <span class="p">[</span><span class="n">NSMutableDictionary</span> <span class="n">new</span><span class="p">];</span>
+ <span class="n">NSArray</span> <span class="o">*</span><span class="n">arr</span> <span class="o">=</span> <span class="p">[</span><span class="n">operation</span><span class="p">.</span><span class="n">responseString</span> <span class="n">componentsSeparatedByCharactersInSet</span><span class="o">:</span>
+ <span class="p">[</span><span class="n">NSCharacterSet</span> <span class="n">characterSetWithCharactersInString</span><span class="o">:</span><span class="s">@"=&amp;"</span><span class="p">]];</span>
+ <span class="k">if</span><span class="p">([</span><span class="n">arr</span> <span class="n">count</span><span class="p">]</span> <span class="o">==</span> <span class="mi">4</span><span class="p">)</span> <span class="p">{</span>
+ <span class="p">[</span><span class="n">requestTokens</span> <span class="n">setObject</span><span class="o">:</span><span class="p">[</span><span class="n">arr</span> <span class="n">objectAtIndex</span><span class="o">:</span><span class="mi">1</span><span class="p">]</span> <span class="n">forKey</span><span class="o">:</span><span class="p">[</span><span class="n">arr</span> <span class="n">objectAtIndex</span><span class="o">:</span><span class="mi">0</span><span class="p">]];</span>
+ <span class="p">[</span><span class="n">requestTokens</span> <span class="n">setObject</span><span class="o">:</span><span class="p">[</span><span class="n">arr</span> <span class="n">objectAtIndex</span><span class="o">:</span><span class="mi">3</span><span class="p">]</span> <span class="n">forKey</span><span class="o">:</span><span class="p">[</span><span class="n">arr</span> <span class="n">objectAtIndex</span><span class="o">:</span><span class="mi">2</span><span class="p">]];</span>
+ <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
+ <span class="n">NSLog</span><span class="p">(</span><span class="s">@"failed ahh"</span><span class="p">);</span>
+ <span class="p">}</span>
+ <span class="p">[</span><span class="n">_window</span> <span class="n">addSubview</span><span class="o">:</span><span class="n">oauthWebView</span><span class="p">];</span>
+ <span class="n">NSString</span> <span class="o">*</span><span class="n">urlToLoad</span> <span class="o">=</span> <span class="p">[</span><span class="n">NSString</span> <span class="n">stringWithFormat</span><span class="o">:</span><span class="s">@"%@/oauth/authorize?%@"</span><span class="p">,</span> <span class="p">[[</span><span class="n">DIOSSession</span> <span class="n">sharedSession</span><span class="p">]</span> <span class="n">baseURL</span><span class="p">],</span> <span class="n">operation</span><span class="p">.</span><span class="n">responseString</span><span class="p">];</span>
+ <span class="n">NSURL</span> <span class="o">*</span><span class="n">url</span> <span class="o">=</span> <span class="p">[</span><span class="n">NSURL</span> <span class="n">URLWithString</span><span class="o">:</span><span class="n">urlToLoad</span><span class="p">];</span>
+ <span class="n">NSLog</span><span class="p">(</span><span class="s">@"loading url :%@"</span><span class="p">,</span> <span class="n">urlToLoad</span><span class="p">);</span>
+ <span class="c1">//URL Requst Object</span>
+ <span class="n">NSURLRequest</span> <span class="o">*</span><span class="n">requestObj</span> <span class="o">=</span> <span class="p">[</span><span class="n">NSURLRequest</span> <span class="n">requestWithURL</span><span class="o">:</span><span class="n">url</span><span class="p">];</span>
+
+ <span class="c1">//Load the request in the UIWebView.</span>
+ <span class="p">[</span><span class="n">oauthWebView</span> <span class="n">loadRequest</span><span class="o">:</span><span class="n">requestObj</span><span class="p">];</span>
+ <span class="p">}</span> <span class="n">failure</span><span class="o">:^</span><span class="p">(</span><span class="n">AFHTTPRequestOperation</span> <span class="o">*</span><span class="n">operation</span><span class="p">,</span> <span class="n">NSError</span> <span class="o">*</span><span class="n">error</span><span class="p">)</span> <span class="p">{</span>
+ <span class="n">NSLog</span><span class="p">(</span><span class="s">@"failed"</span><span class="p">);</span>
+ <span class="p">}];</span>
+</pre></div>
+
+<p>If you want to get back a notificaiton when the request tokens have been authorized youll need to register a URL
+for your application and make sure it is defined in your oAuth consumer which you created on your Drupal website</p>
+
+<p>Again, another example here, we registered our app url and this method gets called when it does.</p>
+
+<div class="highlight highlight-obj-c"><pre><span class="k">-</span> <span class="p">(</span><span class="kt">BOOL</span><span class="p">)</span><span class="nf">application:</span><span class="p">(</span><span class="n">UIApplication</span> <span class="o">*</span><span class="p">)</span><span class="nv">application</span> <span class="nf">handleOpenURL:</span><span class="p">(</span><span class="n">NSURL</span> <span class="o">*</span><span class="p">)</span><span class="nv">url</span>
+<span class="p">{</span>
+ <span class="c1">//If our request tokens were validated, this will get called.</span>
+ <span class="k">if</span> <span class="p">([[</span><span class="n">url</span> <span class="n">absoluteString</span><span class="p">]</span> <span class="n">rangeOfString</span><span class="o">:</span><span class="p">[</span><span class="n">requestTokens</span> <span class="n">objectForKey</span><span class="o">:</span><span class="s">@"oauth_token"</span><span class="p">]].</span><span class="n">location</span> <span class="o">!=</span> <span class="n">NSNotFound</span><span class="p">)</span> <span class="p">{</span>
+ <span class="p">[</span><span class="n">DIOSSession</span> <span class="n">getAccessTokensWithRequestTokens</span><span class="o">:</span><span class="n">requestTokens</span> <span class="n">success</span><span class="o">:^</span><span class="p">(</span><span class="n">AFHTTPRequestOperation</span> <span class="o">*</span><span class="n">operation</span><span class="p">,</span> <span class="kt">id</span> <span class="n">responseObject</span><span class="p">)</span> <span class="p">{</span>
+ <span class="n">NSArray</span> <span class="o">*</span><span class="n">arr</span> <span class="o">=</span> <span class="p">[</span><span class="n">operation</span><span class="p">.</span><span class="n">responseString</span> <span class="n">componentsSeparatedByCharactersInSet</span><span class="o">:</span>
+ <span class="p">[</span><span class="n">NSCharacterSet</span> <span class="n">characterSetWithCharactersInString</span><span class="o">:</span><span class="s">@"=&amp;"</span><span class="p">]];</span>
+ <span class="k">if</span><span class="p">([</span><span class="n">arr</span> <span class="n">count</span><span class="p">]</span> <span class="o">==</span> <span class="mi">4</span><span class="p">)</span> <span class="p">{</span>
+ <span class="c1">//Lets set our access tokens now</span>
+ <span class="p">[[</span><span class="n">DIOSSession</span> <span class="n">sharedSession</span><span class="p">]</span> <span class="n">setAccessToken</span><span class="o">:</span><span class="p">[</span><span class="n">arr</span> <span class="n">objectAtIndex</span><span class="o">:</span><span class="mi">1</span><span class="p">]</span> <span class="n">secret</span><span class="o">:</span><span class="p">[</span><span class="n">arr</span> <span class="n">objectAtIndex</span><span class="o">:</span><span class="mi">3</span><span class="p">]];</span>
+ <span class="n">NSDictionary</span> <span class="o">*</span><span class="n">node</span> <span class="o">=</span> <span class="p">[</span><span class="n">NSDictionary</span> <span class="n">dictionaryWithObject</span><span class="o">:</span><span class="s">@"1"</span> <span class="n">forKey</span><span class="o">:</span><span class="s">@"nid"</span><span class="p">];</span>
+ <span class="p">[</span><span class="n">DIOSNode</span> <span class="n">nodeGet</span><span class="o">:</span><span class="n">node</span> <span class="n">success</span><span class="o">:^</span><span class="p">(</span><span class="n">AFHTTPRequestOperation</span> <span class="o">*</span><span class="n">operation</span><span class="p">,</span> <span class="kt">id</span> <span class="n">responseObject</span><span class="p">)</span> <span class="p">{</span>
+ <span class="n">NSLog</span><span class="p">(</span><span class="s">@"%@"</span><span class="p">,</span> <span class="n">responseObject</span><span class="p">);</span>
+ <span class="p">}</span> <span class="n">failure</span><span class="o">:^</span><span class="p">(</span><span class="n">AFHTTPRequestOperation</span> <span class="o">*</span><span class="n">operation</span><span class="p">,</span> <span class="n">NSError</span> <span class="o">*</span><span class="n">error</span><span class="p">)</span> <span class="p">{</span>
+ <span class="n">NSLog</span><span class="p">(</span><span class="s">@"%@"</span><span class="p">,</span> <span class="p">[</span><span class="n">error</span> <span class="n">localizedDescription</span><span class="p">]);</span>
+ <span class="p">}];</span>
+ <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
+ <span class="n">NSLog</span><span class="p">(</span><span class="s">@"failed ahh"</span><span class="p">);</span>
+ <span class="p">}</span>
+ <span class="n">NSLog</span><span class="p">(</span><span class="s">@"successfully added accessTokens"</span><span class="p">);</span>
+ <span class="p">[</span><span class="n">oauthWebView</span> <span class="n">removeFromSuperview</span><span class="p">];</span>
+ <span class="p">}</span> <span class="n">failure</span><span class="o">:^</span><span class="p">(</span><span class="n">AFHTTPRequestOperation</span> <span class="o">*</span><span class="n">operation</span><span class="p">,</span> <span class="n">NSError</span> <span class="o">*</span><span class="n">error</span><span class="p">)</span> <span class="p">{</span>
+ <span class="n">NSLog</span><span class="p">(</span><span class="s">@"getting access tokens failed"</span><span class="p">);</span>
+ <span class="p">[</span><span class="n">oauthWebView</span> <span class="n">removeFromSuperview</span><span class="p">];</span>
+ <span class="p">}];</span>
+ <span class="p">}</span>
+ <span class="k">return</span> <span class="nb">YES</span><span class="p">;</span>
+<span class="p">}</span>
+</pre></div>
<h2>
<a name="documentation" class="anchor" href="#documentation"><span class="octicon octicon-link"></span></a>Documentation</h2>
@@ -122,7 +197,7 @@
<p>You no longer really need to subclass any existing DIOS classes, unless you want to override.
<code>[DIOSSession shared]</code> ensures that session information is stored for as long as the cookies are valid
If you do want to make your own object, just follow the pattern in the other files and everything should work fine.
-Use the issue queue here on github if you have questions.</p>
+Use the issue queue here on github if you have questions. An addon library is <a href="https://github.com/utneon/drupal-ios-sdk-addons">here</a></p>
<h2>
<a name="questions" class="anchor" href="#questions"><span class="octicon octicon-link"></span></a>Questions</h2>
View
2 params.json
@@ -1 +1 @@
-{"name":"Drupal-ios-sdk","tagline":"The Drupal iOS iPhone & iPad Software Development Kit provides a full suite of iOS features to natively connect iOS applications to Drupal. Formerly KBDrupalConnect","body":"Drupal iOS SDK - Connect your iOS/OS X app to Drupal\r\n================================\r\nWhat you need to know\r\n================================\r\nThe Drupal iOS SDK is a standard set of libraries for communicating to Drupal from any iOS device. Its extremely simple.\r\nIf you wanted to get a node you can do so by instantiating a DIOSNode Object, creating an \r\nNSDictionairy and running the nodeGet method. Heres an example:\r\n\r\n```obj-c\r\n DIOSNode *node = [[DIOSNode alloc] init];\r\n NSMutableDictionary *nodeData = [NSMutableDictionary new];\r\n [nodeData setValue:@\"12\" forKey:@\"nid\"];\r\n [node nodeGet:nodeData success:^(AFHTTPRequestOperation *operation, id responseObject) {\r\n //Do Something with the responseObject\r\n NSLog(@\"%@\", responseObject);\r\n } failure:^(AFHTTPRequestOperation *operation, NSError *error) {\r\n //we failed, uh-oh lets error log this.\r\n NSLog(@\"%@, %@\", [error localizedDescription], [operation responseString]); \r\n }];\r\n \r\n```\r\nFor every DIOS Object you make, any method calls that are available to you use blocks. \r\nThis allows us to define what happens when we have a request that fails or succeeds. \r\nIf the request was successful the result would be something like this:\r\n\r\n {\"vid\":\"9\",\"uid\":\"57\",\"title\":\"testtitle\",\"log\":\"\",\"status\":\"1\".......\r\n \r\nHowever if it failed, the error might look like this:\r\n\r\n Expected status code in (200-299), got 404, \"Node 5 could not be found\"\r\n \r\nWhat you need to get started\r\n================================\r\n* This library :) \r\n* AFNetwork which can be found [here](https://github.com/AFNetworking/AFNetworking)\r\n* Be sure to follow the AFNetworking installation guide.\r\n* Update Settings.h with the correct correct url and endpoints)\r\n* [Services](http://github.com/kylebrowning/services)\r\n\r\nDemo App (Work in progress)\r\n--------------------\r\n[http://github.com/workhabitinc/drupal-ios-sdk-example](http://github.com/workhabitinc/drupal-ios-sdk-example)\r\n\r\nBranches\r\n--------------------\r\n6.x-2.x 6.x-3.x and 7.x-3.x have all been moved to a *DEPRECATED* version of their branch.\r\nThe new dev branch will be the become the new master and as things are added, versions will be tagged and published.\r\nmaster will always be the latest and greatest for the most up to date version of everything(Services, Drupal, Services Api, DIOS).\r\n\r\nTags are in this format\r\n`2.1-1.0` Which breaks down as, DIOSVersion 2.1, Services Api Version 1.0\r\n\r\nBranches are in this format\r\n`2.x-1.x`\r\n\r\nOAuth\r\n--------------------\r\nits coming.\r\n\r\n\r\nDocumentation\r\n-----------\r\n[Can be found here](https://github.com/workhabitinc/drupal-ios-sdk/wiki/drupal-ios-sdk-2.0)\r\n\r\nTroubleshooting\r\n----------\r\nIf you are getting Access denied, or API Key not valid, double check that your key settings are setup correctly at admin/build/services/keys and double check that permissions are correct for your user and anonymous.\r\n\r\nX service doesnt exist in Drupal iOS SDK\r\n----------\r\nYou no longer really need to subclass any existing DIOS classes, unless you want to override.\r\n`[DIOSSession shared]` ensures that session information is stored for as long as the cookies are valid\r\nIf you do want to make your own object, just follow the pattern in the other files and everything should work fine.\r\nUse the issue queue here on github if you have questions.\r\n\r\nQuestions\r\n----------\r\nCheckout the Issue queue, or email me\r\nEmail kylebrowning@me.com","google":"UA-3203637-9","note":"Don't delete this file! It's used internally to help with page regeneration."}
+{"name":"Drupal-ios-sdk","tagline":"The Drupal iOS iPhone & iPad Software Development Kit provides a full suite of iOS features to natively connect iOS applications to Drupal. Formerly KBDrupalConnect","body":"Drupal iOS SDK - Connect your iOS/OS X app to Drupal\r\n================================\r\n##### Originally Sponsored by [http://workhabit.com](http://workhabit.com) built by [Kyle Browning](http://kylebrowning.com)\r\nWhat you need to know\r\n================================\r\nThe Drupal iOS SDK is a standard set of libraries for communicating to Drupal from any iOS device. Its extremely simple.\r\nIf you wanted to get a node you can do so calling some class methods on DIOSNode, creating an \r\nNSDictionary and running the nodeGet method. Heres an example:\r\n\r\n```obj-c\r\n NSMutableDictionary *nodeData = [NSMutableDictionary new];\r\n [nodeData setValue:@\"12\" forKey:@\"nid\"];\r\n [DIOSNode nodeGet:nodeData success:^(AFHTTPRequestOperation *operation, id responseObject) {\r\n //Do Something with the responseObject\r\n NSLog(@\"%@\", responseObject);\r\n } failure:^(AFHTTPRequestOperation *operation, NSError *error) {\r\n //we failed, uh-oh lets error log this.\r\n NSLog(@\"%@, %@\", [error localizedDescription], [operation responseString]); \r\n }];\r\n \r\n```\r\nFor every DIOS call you make, any method calls that are available to you use blocks. \r\nThis allows us to define what happens when we have a request that fails or succeeds. \r\nIf the request was successful the result would be something like this:\r\n\r\n {\"vid\":\"9\",\"uid\":\"57\",\"title\":\"testtitle\",\"log\":\"\",\"status\":\"1\".......\r\n \r\nHowever if it failed, the error might look like this:\r\n\r\n Expected status code in (200-299), got 404, \"Node 5 could not be found\"\r\n \r\nWhat you need to get started\r\n================================\r\n* This library :) \r\n* AFNetwork which can be found [here](https://github.com/AFNetworking/AFNetworking)\r\n* Be sure to follow the AFNetworking installation guide.\r\n* Update Settings.h with the correct correct url and endpoints)\r\n* [Services](http://drupal.org/project/services)\r\n\r\n\r\nExtras\r\n===============================\r\n[Drupal iOS SDK Addons](https://github.com/utneon/drupal-ios-sdk-addons)\r\nDemo App (Work in progress)\r\n--------------------\r\n[http://github.com/workhabitinc/drupal-ios-sdk-example](http://github.com/workhabitinc/drupal-ios-sdk-example)\r\n\r\nBranches\r\n--------------------\r\n6.x-2.x 6.x-3.x and 7.x-3.x have all been moved to a *DEPRECATED* version of their branch.\r\nThe new dev branch will be the become the new master and as things are added, versions will be tagged and published.\r\nmaster will always be the latest and greatest for the most up to date version of everything(Services, Drupal, Services Api, DIOS).\r\n\r\nTags are in this format\r\n`2.1-1.0` Which breaks down as, DIOSVersion 2.1, Services Api Version 1.0\r\n\r\nBranches are in this format\r\n`2.x-1.x`\r\n\r\nOAuth\r\n--------------------\r\nIf you want to use oAuth theres only one thing you need to do for 2-legged\r\n```obj-c\r\n [DIOSSession sharedOauthSessionWithURL:@\"http://d7.workhabit.com\" consumerKey:@\"yTkyapFEPAdjkW7G2euvJHhmmsURaYJP\" secret:@\"ZzJymFtvgCbXwFeEhivtF67M5Pcj4NwJ\"];\r\n```\r\nThis will create your shared session with the baseURL and attach your consumer key and secret.\r\n\r\n3-legged requires that you get some request tokens, and convert them into access tokens.\r\nDIOS provides methods to do this, as an Example, this code will grab some request tokens and load a webview to be displayed\r\n\r\n```obj-c\r\n [DIOSSession getRequestTokensWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {\r\n requestTokens = [NSMutableDictionary new];\r\n NSArray *arr = [operation.responseString componentsSeparatedByCharactersInSet:\r\n [NSCharacterSet characterSetWithCharactersInString:@\"=&\"]];\r\n if([arr count] == 4) {\r\n [requestTokens setObject:[arr objectAtIndex:1] forKey:[arr objectAtIndex:0]];\r\n [requestTokens setObject:[arr objectAtIndex:3] forKey:[arr objectAtIndex:2]];\r\n } else {\r\n NSLog(@\"failed ahh\");\r\n }\r\n [_window addSubview:oauthWebView];\r\n NSString *urlToLoad = [NSString stringWithFormat:@\"%@/oauth/authorize?%@\", [[DIOSSession sharedSession] baseURL], operation.responseString];\r\n NSURL *url = [NSURL URLWithString:urlToLoad];\r\n NSLog(@\"loading url :%@\", urlToLoad);\r\n //URL Requst Object\r\n NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];\r\n\r\n //Load the request in the UIWebView.\r\n [oauthWebView loadRequest:requestObj];\r\n } failure:^(AFHTTPRequestOperation *operation, NSError *error) {\r\n NSLog(@\"failed\");\r\n }];\r\n```\r\n\r\nIf you want to get back a notificaiton when the request tokens have been authorized youll need to register a URL\r\nfor your application and make sure it is defined in your oAuth consumer which you created on your Drupal website\r\n\r\nAgain, another example here, we registered our app url and this method gets called when it does.\r\n\r\n```obj-c\r\n- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url\r\n{\r\n //If our request tokens were validated, this will get called.\r\n if ([[url absoluteString] rangeOfString:[requestTokens objectForKey:@\"oauth_token\"]].location != NSNotFound) {\r\n [DIOSSession getAccessTokensWithRequestTokens:requestTokens success:^(AFHTTPRequestOperation *operation, id responseObject) {\r\n NSArray *arr = [operation.responseString componentsSeparatedByCharactersInSet:\r\n [NSCharacterSet characterSetWithCharactersInString:@\"=&\"]];\r\n if([arr count] == 4) {\r\n //Lets set our access tokens now\r\n [[DIOSSession sharedSession] setAccessToken:[arr objectAtIndex:1] secret:[arr objectAtIndex:3]];\r\n NSDictionary *node = [NSDictionary dictionaryWithObject:@\"1\" forKey:@\"nid\"];\r\n [DIOSNode nodeGet:node success:^(AFHTTPRequestOperation *operation, id responseObject) {\r\n NSLog(@\"%@\", responseObject);\r\n } failure:^(AFHTTPRequestOperation *operation, NSError *error) {\r\n NSLog(@\"%@\", [error localizedDescription]);\r\n }];\r\n } else {\r\n NSLog(@\"failed ahh\");\r\n }\r\n NSLog(@\"successfully added accessTokens\");\r\n [oauthWebView removeFromSuperview];\r\n } failure:^(AFHTTPRequestOperation *operation, NSError *error) {\r\n NSLog(@\"getting access tokens failed\");\r\n [oauthWebView removeFromSuperview];\r\n }];\r\n }\r\n return YES;\r\n}\r\n```\r\nDocumentation\r\n-----------\r\n[Can be found here](https://github.com/workhabitinc/drupal-ios-sdk/wiki/drupal-ios-sdk-2.0)\r\n\r\nTroubleshooting\r\n----------\r\nIf you are getting Access denied, or API Key not valid, double check that your key settings are setup correctly at admin/build/services/keys and double check that permissions are correct for your user and anonymous.\r\n\r\nX service doesnt exist in Drupal iOS SDK\r\n----------\r\nYou no longer really need to subclass any existing DIOS classes, unless you want to override.\r\n`[DIOSSession shared]` ensures that session information is stored for as long as the cookies are valid\r\nIf you do want to make your own object, just follow the pattern in the other files and everything should work fine.\r\nUse the issue queue here on github if you have questions. An addon library is [here](https://github.com/utneon/drupal-ios-sdk-addons)\r\n\r\nQuestions\r\n----------\r\nCheckout the Issue queue, or email me\r\nEmail kylebrowning@me.com","google":"UA-3203637-9","note":"Don't delete this file! It's used internally to help with page regeneration."}

0 comments on commit 7ef5b8c

Please sign in to comment.