gpt4 book ai didi

ios - 如何在Twitter中将URL发送给 friend

转载 作者:行者123 更新时间:2023-12-01 18:58:49 25 4
gpt4 key购买 nike

如何在iOS中将URL发送给Twitter friend 。
我可以发送直接消息,但不允许我发送URL。

这是我的将Dritrect消息发布到Twitter Friend及其工作的代码。

-(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而不是它,则返回此错误
{
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-or-deleting-direct-messages

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

关于ios - 如何在Twitter中将URL发送给 friend ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24383118/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com