我使用以下代码在我的应用程序中调用操作表共享:
- (IBAction)sendPost:(id)sender
{
NSArray *activityItems = nil;
UIImage *appIcon = [UIImage imageNamed:@"appIcon.png"];
NSString *postText = [[NSString alloc] initWithFormat:@"LETS ASSUME THIS STRING IS LONGER THAN 140 CHARACTERS THAT TWITTER PROHIBITS BUT CAN STILL BE SHARED VIA FACEBOOK, EMAIL, TEXT"];
activityItems = @[postText,appIcon];
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityController animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
问题是这个:postText超过140个字符,所以不可能通过twitter分享,字符数将是-x(你通过twitter分享的红色字符数),我的问题是:怎么能我做了一个例外,以便shortPostText在选择Twitter进行共享时使用的是另一条消息吗?
一旦你sendPost发送了动作,我就看不到为twitter明确设置字符串的方法了:

编辑:我不明白为什么有人会对这个问题进行投票,我不会问如何制作if/else语句或如何编程.这是一个真正的问题,需要一个真正的答案.
更新:我需要解决这个问题,因为当用户尝试通过我的应用程序中的Twitter共享时,这是我得到的:

红色/负号字符指示符和非活动帖子按钮,因此除非字符数减少到0或更少,否则不允许帖子转到twitter.
我正在使用iOs社交框架来从特定用户检索Facebook提要.为此,在进行身份验证后,我正在执行以下操作:
NSURL *requestURL = [NSURL URLWithString:@"https://graph.facebook.com/username"];
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET
URL:requestURL parameters:nil];
request.account = self.facebookAccount;
[request performRequestWithHandler:^(NSData *data, NSHTTPURLResponse *response, NSError *error) { ... }];
Run Code Online (Sandbox Code Playgroud)
响应返回:
error = {
code = 803;
message = "(#803) Cannot query users by their username (username)";
type = OAuthException;
};
Run Code Online (Sandbox Code Playgroud)
如果我使用/me而不是用户名,同样的工作,但我想检索其他公共提要.
我也尝试使用用户的id,这也适用于我的用户,但我不能为其他用户工作,请求返回以下内容:
code = 2500;
message = "The global ID 100008339709776 is not allowed. Please use the application specific ID instead.";
type = OAuthException;
Run Code Online (Sandbox Code Playgroud)
我也尝试将访问令牌作为参数传递,但行为是相同的.
有任何想法吗?
如果他们尚未登录,是否有人知道如何让用户输入他们的Facebook或Twitter帐户登录信息?例如,用户尝试使用Facebook登录我的应用程序,而无需在iOS设置中配置Facebook帐户.例如,我可以要求他以警报方式进行此操作,但是如何将他带到设置的确切部分呢?
我目前正在使用SLComposeViewController将用户的分数发布到twitter或facebook(取决于他们点击的按钮).当他们分享时,他们会获得虚拟货币奖励.我面临的问题是它只会告诉我用户是否点击发送或取消.如何检查推文是否实际发布到Twitter?这将有助于打击用户尝试两次提交相同推文的情况(twitter不允许).
这是我现在的代码:
//Check if user can send tweet
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
tweetSheet.completionHandler = ^(SLComposeViewControllerResult result) {
switch(result) {
//This means the user cancelled without sending the Tweet
case SLComposeViewControllerResultCancelled:
NSLog(@"User Canceled");
break;
//This means the user hit 'Send'
case SLComposeViewControllerResultDone:
NSLog(@"User Tapped Send");
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
//Show alert & reward user here
break;
}
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissViewControllerAnimated:NO completion:^{
NSLog(@"Tweet Sheet has been dismissed.");
}];
});
};
[tweetSheet setInitialText:[NSString stringWithFormat:@"Just scored …Run Code Online (Sandbox Code Playgroud) 使用TWRequest时,Instruments(Leaks)报告内存泄漏,我无法真正看到我做错了什么.
以下是重现问题的步骤:
创建一个新的Xcode项目(禁用ARC),添加Twitter框架,然后将以下行添加到代码中(例如在viewDidLoad中):
TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"http://api.twitter.com/1/statuses/public_timeline.json"] parameters:nil requestMethod:TWRequestMethodGET];
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSLog(@"in performrequest");
[postRequest release];
}];
Run Code Online (Sandbox Code Playgroud)
在使用Instruments(Leaks)分析此代码之后,它告诉我带有"performRequestWithHandler"的行正在泄漏:


有什么想法可以防止这种泄漏?
我注意到Mobile Safari的Twitter和Facebook共享添加了当前页面的屏幕截图而没有实际共享它,例如:

我试图通过SLComposeViewController复制它,但是调用addImage:实际上将UIImage添加到tweet/facebook相册(如预期的那样).
有没有办法只显示页面的屏幕截图而不添加图像?
编辑:看起来SLComposeViewController符合UIAppearanceContainer但是UI_APPEARANCE_SELECTOR没有记录.
objective-c ios ios6 slcomposeviewcontroller social-framework
我正在使用iOS 6 Social框架来访问用户的Facebook数据.我试图用我的应用程序中的当前用户喜欢ACAccount和SLRequest.我有一个ACAccount名为的有效Facebook帐户参考,facebook我试图让用户喜欢这样:
SLRequest *req = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:url parameters:nil];
req.account = facebook;
[req performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
//my handler code.
}
Run Code Online (Sandbox Code Playgroud)
这里url是@"https://graph.facebook.com/me/likes?fields=name";在我的处理程序,我得到这样的响应:
{
error = {
code = 2500;
message = "An active access token must be used to query information about the current user.";
type = OAuthException;
};
}
Run Code Online (Sandbox Code Playgroud)
框架不应该处理访问令牌吗?我发现了一个类似的帖子通过新的iOS6社交框架查询Facebook用户数据,但是将访问令牌参数硬编码到URL中是没有意义的,因为逻辑上访问令牌/登录检查应该由框架自动处理.在我看过的所有示例中,没有人手动使用访问令牌:
http://damir.me/posts/facebook-authentication-in-ios-6
iOS 6 Facebook发布程序最终以"remote_app_id与存储ID不匹配"错误 等结束.
我使用iOS6专用方法和内置的社交框架,我没有使用Facebook SDK.我错过了什么吗?
谢谢,
能够.
我正在尝试使用iOS 6+中的社交框架在我的facebook朋友墙上发布iOS应用程序的邀请.但它给了我以下错误
error = {
code = 200;
message = "(#200) Feed story publishing to other users is disabled for this application";
type = OAuthException;
};
Run Code Online (Sandbox Code Playgroud)
我知道这是由于Facebook禁用Facebook博客和此stackoverflow问题中提到的此功能
在stackoverlow的页面上,写入使用feed对话框.但我看不到在Social框架中使用feed对话框的任何选项.
在iOS 6中使用Social Framewrok在朋友墙上进行POST的替代方法是什么?
任何形式的帮助表示赞赏.提前致谢.
是否可以使用SLRequest共享视频?
我可以使用相同的方式共享图像
SLRequest *postRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:requestURL parameters:message];
if (isImage)
{
NSData *data = UIImagePNGRepresentation(imgSelected);
[postRequest addMultipartData:data withName:@"media" type:@"image/png" filename:@"TestImage.png"];
}
postRequest.account = account;
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
{
if (!error)
{
NSLog(@"Upload Sucess !");
}
}];
Run Code Online (Sandbox Code Playgroud) 我正在尝试整合Ios 6和twitter以使用slcomposeviewcontroller发送推文,但我无法弄清楚如何从Twitter帐户获取用户信息.
有谁能够帮我?
social-framework ×10
ios ×7
ios6 ×5
objective-c ×5
twitter ×5
facebook ×2
acaccount ×1
instruments ×1
memory-leaks ×1
twrequest ×1
video ×1