如何在Twitter中将URL发送给朋友 [英] How to send URL to Friend in Twitter

查看:164
本文介绍了如何在Twitter中将URL发送给朋友的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在iOS中将URL发送给Twitter朋友.我可以发送直接消息,但不允许我在其中发送URL.

How can i send the URL to twitter friend in iOS. I can send direct message but it does not allow me to send URL in it.

这是我的代码,用于向Twitter Friend投递Drirect消息及其工作方式.

Here is my code for Posting Drirect message to Twitter Friend and its working.

-(void)postMessageToFriend:(NSString *)ID withMessage:(NSString *)message {

    NotificatioName = notificationNameStr;

    ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
    [accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {

        if (granted && !error) {

            NSArray *accountsListAry = [accountStore accountsWithAccountType:accountType];

            int NoOfAccounts = [accountsListAry count];
            if (NoOfAccounts >0) {

                NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/1.1/direct_messages/new.json"];
                twitterAccount = [accountsListAry lastObject];

                NSDictionary *p =@{@"status":@"Posted",@"screen_name":ID, @"text":message};
                SLRequest *postRequest = [SLRequest  requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:url parameters:p];

                [postRequest setAccount:twitterAccount];
                [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResposnse, NSError *error){
                    if (error) {
                        NSLog(@"error : %@",error);
                    }else{
                        NSError *jsonError = nil;

                        NSString * responseStr = [[NSString alloc] initWithData:responseData encoding:NSJSONWritingPrettyPrinted];

                        NSArray *friendsdata =
                        [NSJSONSerialization JSONObjectWithData: [responseStr dataUsingEncoding:NSUTF8StringEncoding]
                                                        options: NSJSONReadingMutableContainers
                                                          error: &jsonError];
                        NSLog(@"response value is: %@ %d ",friendsdata,[urlResposnse statusCode]);

                    }
                }];
            }
        }
    }];
}

但是,如果我尝试在邮件中添加URL而不是返回该错误

But If i try to add URL in my message than its return me this error

{
    errors =     (
                {
            code = 226;
            message = "This request looks like it might be automated. To protect our users from spam and other malicious activity, we can't complete this action right now. Please try again later.";
        }
    );
}

推荐答案

我认为与Twitter无关,与您的代码无关.显然,他们不允许在直接消息中发送链接. https://support.twitter.com/articles/14606-posting-或删除直接消息.

I think it has nothing to do with your code, but with Twitter. Apparently, they're not allowing to send links in direct messages. https://support.twitter.com/articles/14606-posting-or-deleting-direct-messages.

即使是来自官方Twitter客户或其网站的用户,您也无法做到这一点.AFAIK,这是一个已知问题,据说他们正在努力.但是,自从他们这么说以来已经很久了.

You can't do that even as a user from the official twitter client or from their website. AFAIK, it's a known issue and they're said to be working on it. But it's been long since they said that.

这篇关于如何在Twitter中将URL发送给朋友的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆