菜鸟教程小白 发表于 2022-12-12 21:48:02

ios - 如何使用 cookie 在 Instagram 中进行身份验证?


                                            <p><p>所以我有我的 auth instagram 代码。 token 已提供但无法使用并显示消息“<code>You must to switch cookies</code>”。我必须做什么?感谢您的回答。</p>

<p>现在我尝试从 instagram 获取 token :</p>

<pre><code>NSURL *url=;

NSMutableURLRequest *request = [ init];
;
;
;
NSData *urlData;
NSHTTPURLResponse *response;
NSError *errors;
urlData = ;

NSString *string = [ initWithData:urlData encoding:NSUTF8StringEncoding];

NSRegularExpression *regex = ;
NSString *token = string;
NSTextCheckingResult *match = )];


NSString *str = [] stringByReplacingOccurrencesOfString:@&#34;\&#34;}&#34;
                                     withString:@&#34;&#34;];

NSLog(@&#34;%@&#34;, str);

NSString *post = ;

NSData *postData = ;

NSString *postLength = ];

request = [ init];
];
;
;
;
;
;

urlData = ;

NSString *string2 = [ initWithData:urlData encoding:NSUTF8StringEncoding];

NSLog(@&#34;%@&#34;, string2);
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><pre><code>NSDictionary *cookieProperties = [NSDictionary dictionaryWithObjectsAndKeys:
                                  @&#34;&#34;, NSHTTPCookieDomain,
                                  @&#34;\\&#34;, NSHTTPCookiePath,
                                  @&#34;csrftoken&#34;, NSHTTPCookieName,
                                  @&#34;2dfdbaaeae7752882d792e49d79c0048&#34;, NSHTTPCookieValue,
                                  nil];
NSHTTPCookie *cookie = ;
NSArray* cookieArray = ;
NSDictionary * headers = ;
</code></pre>

<p>在 POST 请求中添加:
[请求 setAllHTTPHeaderFields:headers];</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 如何使用 cookie 在 Instagram 中进行身份验证?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/23220751/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/23220751/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 如何使用 cookie 在 Instagram 中进行身份验证?