Live video. (#100) No permission to perform current operation - ios

I want to make live video stream from my IOS app to Facebook. I have two facebook account: first - with registered iOS app, second account - only for the test. If I log in with my first account(in my iOS app) - I get the required rtmp://rtmp-api.facebook.com:80/rtmp URL and secret key for the streaming (everything as stated on the FB documentation: https://developers.facebook.com/docs/videos/live-video-api). But if I'm using second account for login, I'm receiving this error:
com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={
body = {
error = {
code = 100;
"fbtrace_id" = Ed9BmMChIsn;
message = "(#100) No permission to perform current operation.";
type = OAuthException;
};
};
code = 400;
}, com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=400,
My code for live streaming:
- (void)enableFacebookLiveStreamingWithCompletionHandler:(void(^)(NSString* facebookStreamURL, NSString* facebookStreamKey, NSError* error))completionHandler;
{
dispatch_async(dispatch_get_main_queue(), ^{
if ([[FBSDKAccessToken currentAccessToken] hasGranted:permissionPublishActions])
{
NSString* liveVideosRequestPath = [NSString stringWithFormat:#"/%#/live_videos",[FBSDKAccessToken currentAccessToken].userID];
FBSDKGraphRequest* request = [[FBSDKGraphRequest alloc] initWithGraphPath:liveVideosRequestPath parameters:nil HTTPMethod:#"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
NSLog(#"%#",[FBSDKAccessToken currentAccessToken].permissions);
if (error)
{
if (completionHandler)
completionHandler(#"",#"",error);
}
else
{
if (completionHandler)
completionHandler(#"rtmp://rtmp-api.facebook.com:80/rtmp/",[[result objectForKey:#"stream_url"] lastPathComponent],nil);
}
}];
}
});
}
P.S// Very interesting that even though I have included all the permissions here: https://developers.facebook.com/tools/explorer, all the same to me denied access for second account for testing(on which the application is not registered)!
Help me please.

Most permissions need to get reviewed by Facebook, else you can only use them as users with a role in the App. Read about "Login Review" in the docs: https://developers.facebook.com/docs/facebook-login/review

Related

Unable to fetch user's email from twitter using twitter fabric iOS framework

I am trying my hands on new fabric twitter kit for iOS.
After signing in we can ask user to allow access for the email id and if it allows then returns email of the logged in user but it giving me error.
Email (null), Error: Error Domain=NSURLErrorDomain Code=-1001
"The request timed out." UserInfo=0x7fdd314f1c30
{NSUnderlyingError=0x7fdd314d9aa0 "The request timed out.",
NSErrorFailingURLStringKey=https://api.twitter.com/1.1/account/verify_cre
dentials.json?skip_status=true&include_email=true,
NSErrorFailingURLKey=https://api.twitter.com/1.1/account/verify_credentia
ls.json?skip_status=true&include_email=true,
NSLocalizedDescription=The request timed out.}
And here is my code that i've tried from their doc.
if ([[Twitter sharedInstance] session]) {
TWTRShareEmailViewController* shareEmailViewController =
[[TWTRShareEmailViewController alloc]
initWithCompletion:^(NSString* email, NSError* error) {
NSLog(#"Email %#, Error: %#", email, error);
}];
[self presentViewController:shareEmailViewController
animated:YES
completion:nil];
} else {
// TODO: Handle user not signed in (e.g.
// attempt to log in or show an alert)
}
Is anything wrong in my code? Please help me.
I can post my status and media to twitter but can't get email Id.
Can anyone please help me in this problem? I'm also new to development.
To get user email address, your application should be whitelisted. Here is the link. Go to use this form. You can either send mail to sdk-feedback#twitter.com with some details about your App like Consumer key, App Store link of an App, Link to privacy policy, Metadata, Instructions on how to log into our App etc..They will respond within 2-3 working days.
Here is the story how I got whitelisted by conversation with Twitter support team:
Send mail to sdk-feedback#twitter.com with some details about your App like Consumer key, App Store link of an App, Link to privacy policy, Metadata, Instructions on how to log into our App. Mention in mail that you want to access user email adress inside your App.
They will review your App and reply to you withing 2-3 business days.
Once they say that your App is whitelisted, update your App's settings in Twitter Developer portal. Sign in to apps.twitter.com and:
On the 'Settings' tab, add a terms of service and privacy policy URL
On the 'Permissions' tab, change your token's scope to request email. This option will only been seen, once your App gets whitelisted.
Put your hands on code
Use of Twitter framework:
Get user email address
-(void)requestUserEmail
{
if ([[Twitter sharedInstance] session]) {
TWTRShareEmailViewController *shareEmailViewController =
[[TWTRShareEmailViewController alloc]
initWithCompletion:^(NSString *email, NSError *error) {
NSLog(#"Email %# | Error: %#", email, error);
}];
[self presentViewController:shareEmailViewController
animated:YES
completion:nil];
} else {
// Handle user not signed in (e.g. attempt to log in or show an alert)
}
}
Get user profile
-(void)usersShow:(NSString *)userID
{
NSString *statusesShowEndpoint = #"https://api.twitter.com/1.1/users/show.json";
NSDictionary *params = #{#"user_id": userID};
NSError *clientError;
NSURLRequest *request = [[[Twitter sharedInstance] APIClient]
URLRequestWithMethod:#"GET"
URL:statusesShowEndpoint
parameters:params
error:&clientError];
if (request) {
[[[Twitter sharedInstance] APIClient]
sendTwitterRequest:request
completion:^(NSURLResponse *response,
NSData *data,
NSError *connectionError) {
if (data) {
// handle the response data e.g.
NSError *jsonError;
NSDictionary *json = [NSJSONSerialization
JSONObjectWithData:data
options:0
error:&jsonError];
NSLog(#"%#",[json description]);
}
else {
NSLog(#"Error code: %ld | Error description: %#", (long)[connectionError code], [connectionError localizedDescription]);
}
}];
}
else {
NSLog(#"Error: %#", clientError);
}
}
Hope it helps !!!

Facebook graph-API OAuthException Code:368 Misusing this feature by going too fast

I try to publish comments on Pages photos posts by using the following code :
NSDictionary *params = #{#"message" : #"New Comment"};
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:[NSString stringWithFormat:#"/%#/comments", objectId]
parameters:params
HTTPMethod:#"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if(error){
NSLog(#"Error Comment %#", [error description]);
}
else{
NSLog(#"Result Comment %#", [result description]);
}
}];
It works (worked) when I used NSDictionary *params = #{#"message" : #"New Comment"};
But when I tried to use attachment_url as parameters value but then I get this error :
error = {
message:"(#1705) There was an error posting to this wall";
type:"OAuthException";
code:1705
};
I tried to make the calls by using curl and Facebook graph-api explorer and I get same errors.
The page I'm trying to comment on doesn't seem to have particular restrictions.
Now I'm getting the following error :
FBSDKGraphRequestErrorGraphErrorCode=368, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={
body = {
error = {
code = 368;
message = "It looks like you were misusing this feature by going too fast. You've been blocked from using it.Learn more about blocks in the Help Center.";
type = OAuthException;
};
};
code = 400;
}}
I guess I reach a limit of something but I don't know which one. What I am suppose to do know to be able to perform requests on {object-id}/comments again ?
Facebook does not and will not officially post any call limits. The reason they give is: "If you are using the platform responsibility you will not hit any rate limits".
It appears to me you are attempting to spam comments to multiple objects and of course they will block this.
So what is you are trying to do?

Facebook Notification API

Has anyone implemented facebook Notification API in iOS??
I have used it in android its working but for iOS its giving OAuthException.
Its in Beta could be a bug in Notification API??
I am using facebook SDK for iOS v 3.18.
Code
NSString *notification_Id = [NSString stringWithFormat:#"/%#/notifications", friend];
NSString *app_token = #"APP_ID|APP_SECRET";
NSDictionary *dict_notification = #{#"href": url,
#"template": #"You have been invited to Choozr Poll by",
#"access_token" : app_token};
/* make the API call */
[FBRequestConnection startWithGraphPath:notification_Id
parameters:dict_notification
HTTPMethod:#"POST"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
if (error) {
NSLog(#"error: %#", error);
}
NSLog(#"%#",result);
}];
Response from facebook
{ > error = { > code = 15; > message = "(#15) This method must be called with an app access_token."; > type = OAuthException; > }
You need to implement the Facebook notification API on your server side code, not the client.

How to create Facebook test users programmatically using Facebook iOS SDK 3.14.1

We are trying to create Facebook test users using the Facebook iOS SDK 3.14.1 according to their website: https://developers.facebook.com/docs/graph-api/reference/v2.0/app/accounts/test-users
Here is our code:
NSString *fbAccessToken = [NSString stringWithFormat:#"%#",FBSession.activeSession.accessTokenData];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
#"true", #"installed",
fbAccessToken, #"owner_access_token",
nil
];
NSString *path = [NSString stringWithFormat:#"/%#/accounts/test-users", kFacebookID];
/* make the API call */
[FBRequestConnection startWithGraphPath:path ///{app-id}/accounts/test-users"
parameters:nil
HTTPMethod:#"POST"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
)
{
if (result && !error)
{
NSLog(#"Test-User created successfully: %#", result);
}
else
{
NSLog(#"Error creating test-user: %#", error);
NSLog(#"Result Error: %#", result);
}
}];
When we run it we receive the following error:
error = {
code = 15;
message = "(#15) This method must be called with an app access_token.";
type = OAuthException;
};
We have also tried without the parameter owner_access_token but the same error occurs.
How can we create Facebook Test users programmatically using the Facebook iOS SDK?
Solution:
Instead of using the active session access token in you should use the App Token.
Just replace FBSession.activeSession.accessTokenData with your App Token.
The App Token can be found here:
https://developers.facebook.com/tools/accesstoken/
As per WizKid comment above, this is for testing purposes only.

Can you get your Twitter email using the API?

I am developing a iOS App and I have login with Facebook, LinkedIn, Google+ and Twitter.
All of them let me read my email from my profile using API, EXCEPT Twitter.
Is there any way to get my email?
If not, is there in twitter a "internal email", a generated email like in facebook (someone#facebook.com)?
The reason is that I use email as identifier (primary key) for users in my database.
No, email address are not available via the Twitter API: https://dev.twitter.com/discussions/1737
Nor is there any "internal email" available, you will have to use the twitter username and ask the user fro there e-mail address.
You will have to use Twitter framework. Twitter has provided a beautiful framework for that, you just have to integrate it in your app.
To get user email address, your application should be whitelisted. Here is the link. Go to use this form. You can either send mail to sdk-feedback#twitter.com with some details about your App like Consumer key, App Store link of an App, Link to privacy policy, Metadata, Instructions on how to log into our App etc..They will respond within 2-3 working days.
Here is the story how I got whitelisted by conversation with Twitter support team:
Send mail to sdk-feedback#twitter.com with some details about your App like Consumer key, App Store link of an App, Link to privacy policy, Metadata, Instructions on how to log into our App. Mention in mail that you want to access user email adress inside your App.
They will review your App and reply to you withing 2-3 business days.
Once they say that your App is whitelisted, update your App's settings in Twitter Developer portal. Sign in to apps.twitter.com and:
On the 'Settings' tab, add a terms of service and privacy policy URL
On the 'Permissions' tab, change your token's scope to request email. This option will only been seen, once your App gets whitelisted.
Put your hands on code
Use of Twitter framework:
Get user email address
-(void)requestUserEmail
{
if ([[Twitter sharedInstance] session]) {
TWTRShareEmailViewController *shareEmailViewController =
[[TWTRShareEmailViewController alloc]
initWithCompletion:^(NSString *email, NSError *error) {
NSLog(#"Email %# | Error: %#", email, error);
}];
[self presentViewController:shareEmailViewController
animated:YES
completion:nil];
} else {
// Handle user not signed in (e.g. attempt to log in or show an alert)
}
}
Get user profile
-(void)usersShow:(NSString *)userID
{
NSString *statusesShowEndpoint = #"https://api.twitter.com/1.1/users/show.json";
NSDictionary *params = #{#"user_id": userID};
NSError *clientError;
NSURLRequest *request = [[[Twitter sharedInstance] APIClient]
URLRequestWithMethod:#"GET"
URL:statusesShowEndpoint
parameters:params
error:&clientError];
if (request) {
[[[Twitter sharedInstance] APIClient]
sendTwitterRequest:request
completion:^(NSURLResponse *response,
NSData *data,
NSError *connectionError) {
if (data) {
// handle the response data e.g.
NSError *jsonError;
NSDictionary *json = [NSJSONSerialization
JSONObjectWithData:data
options:0
error:&jsonError];
NSLog(#"%#",[json description]);
}
else {
NSLog(#"Error code: %ld | Error description: %#", (long)[connectionError code], [connectionError localizedDescription]);
}
}];
}
else {
NSLog(#"Error: %#", clientError);
}
}
Hope it helps !!!

Resources