getting video thumbnails from vimeo - ios

In my app i want to display the videos uploaded by a particular user in his Vimeo account.
I have completed the OAuth steps and got the video_id's of the video's uploaded by user. I tried to download the thumbnails for videos so that they can be displayed in table view or collection view.
Vimeo has provided the api method using that i got the response like this:
NSURL *url = [[NSURL alloc] initWithString:#"http://vimeo.com/api/rest/v2?format=json&method=vimeo.videos.getThumbnailUrls&video_id=72961770"];
but i pasted the user id there. i tried another approach so that the user id is loaded dynamically.
NSURL *url = [[NSURL alloc] initWithString:#"http://vimeo.com/api/rest/v2?format=json&method=vimeo.videos.getThumbnailUrls"];
OAMutableURLRequest *request = [[OAMutableURLRequest alloc]initWithURL:url consumer:consumer token:token realm:nil signatureProvider:nil];
OARequestParameter *p0 = [[OARequestParameter alloc] initWithName:#"video_id" value:[array objectAtIndex:0]];
NSArray *params = [NSArray arrayWithObject:p0];
[request setParameters:params];
but i got an error saying that Msg = Method not found.
can you help me to get the id dynamically or is there a way to give the video_id as a parameter to the url. Thank you

create a string for url and paste until video_id=.
NSString *url = #"http://vimeo.com/api/rest/v2?format=json&method=vimeo.videos.getThumbnailUrls&video_id=";
and after that use stringByAppendingString method to append the video_id value to it and use it.
This is also not a direct way but somehow enables you to get the video thumbnails dynamically without having to paste it

Related

How to use different User-Agent in different iOS Webview request

I know I can use the below code to change the default agent:
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:#"Your user agent", #"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
but I want to request a different User-Agent for different requests. Examples: request 'www.google.com', use agent=‘google Agent’, request 'www.github.com', use agent='github Agent'.
I have tried the below way to set the 'User_Agent' in each request, but it doesn't seem to work.
- (void)viewDidLoad {
NSString *urlAddress = #"http://www.amazon.com";
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSMutableURLRequest *requestObj = [NSMutableURLRequest requestWithURL:url];
[requestObj setValue:#"Foobar/1.0" forHTTPHeaderField:#"User_Agent"];
// But the value is not "Foobar/1.0"
NSString* secretAgent = [webView stringByEvaluatingJavaScriptFromString:#"navigator.userAgent"];
NSLog(#"agent - %#", secretAgent);
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
}
One more question:
It seems a change to the default agent only work change in 'AppDelegate' or 'initialize'. Am I right? Because I try to change in 'viewDidLoad' but it doesn't seem to work.
I observed that if you load any url in webView with a user-agent set
to it. After some time you load the different url & different user
agent but used the same allocated WebView instane.The web view will
load the new url but can not set new user-agent. It just set old one
that you have set before loading first time.
You can not change untill you initiate new instanse of UIWebview(or
we can say that user agent can be set once per session). So I coame to result that user-agent can be set only once.
What I did for this problem is, I allocated new instance when I want set new user-agent.
You don't need to set it using JavaScript.
You have misspelled User-Agent. Use this minimal code taken from here
NSString* userAgent = #"My Cool User Agent";
NSURL* url = [NSURL URLWithString:#"http://whatsmyuseragent.com/"];
NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:url];
[request setValue:userAgent forHTTPHeaderField:#"User-Agent"];

Using Parse CloudCode to send a pdf attachment via mailgun?

I am using iOS with parse.com and mailgun. I am trying to send an email with a pdf attached. I have read that the parse.com cloudCode doesn't allow attachments. But I have also seen this post, Mailgun: Sending image using parse cloud code ,saying instead of attaching place it inline.
First off, is this still the case, that we cannot send attachments via cloud code? If so, could someone give me a hand in figuring out how to get a pdf from my app into an email sent through mail gun? Im not using the built in mail view from apple because I need to be able to set the "from" address of the email.
I have the pdf created dynamically in the app and I present it in the code like this:
NSString* fileName = #"Invoice.PDF";
NSArray *arrayPaths =
NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory,
NSUserDomainMask,
YES);
NSString *path = [arrayPaths objectAtIndex:0];
NSString* pdfFileName = [path stringByAppendingPathComponent:fileName];
UIWebView* webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 60, 320, 480)];
NSURL *url = [NSURL fileURLWithPath:pdfFileName];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView setScalesPageToFit:YES];
[webView loadRequest:request];
[self.view addSubview:webView];
I don't know how to get the file from the Docdir into the proper data form and either attached (if now possible) or place it inline like the post mentions above.
Any help would be appreciated. If you need more info, have questions or have alternate idea on how to accomplish this task please ask/suggest.
Thanks in advance

Unable to set picture property in FacebookShareParams ios

I am unable able to set the picture property in Facebook share params.
Every time I set it, it always remain nil:
NSURL *url = [[NSURL alloc] initWithString:filePath];
// Check if the Facebook app is installed and we can present the share dialog
FBLinkShareParams *params = [[FBLinkShareParams alloc] init];
params.link = [NSURL URLWithString:#"https://www.google.com"];
params.name = #"Check if it works";
params.caption = #"Yet to fix image capture and publishing it";
params.picture = url;
What is the problem in there?

Compose a Twitter DM without displaying dialog

I see #Cirrostratus answer at
iOS 5 Twitter Framework: Tweeting without user input and confirmation (modal view controller) and it works nicely for a tweet. How would I alter this to send a DM instead?
Got it:
NSString *dmString = #"d #RecipientTwitterName ";
NSString *statusString = [dmString stringByAppendingString:stringForTweet];
postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:#"http://api.twitter.com/1/statuses/update.json"]
parameters:[NSDictionary dictionaryWithObject:statusString forKey:#"status"]
requestMethod:TWRequestMethodPOST];
just prepend the d and your recipient's twitter name.

Facebook feeds on iOS app?

How can I display face book feeds related to a group on an iOS App?
Is there any JSON/JSONP call to fetch the feeds??
Any help is Appreciated.
The simplest - is just to show a web page on web view. Facebook manages itself to fit the width of your webView control.
// Load facebook data
NSString *fbUrlAddress = #"http://www.facebook.com/FLORtiles"; // here you put your own group
//Create a URL object.
NSURL *fbUrl = [NSURL URLWithString:fbUrlAddress];
NSString *webHTMLfb = [NSString stringWithContentsOfURL:fbUrl encoding:NSUTF8StringEncoding error:NULL];
//NSLog(#"webHTML of facebook: %#", webHTMLfb);
//URL Requst Object
NSURLRequest *fbRequestObj = [NSURLRequest requestWithURL:fbUrl];
//Load the request in the UIWebView.
[fbWebView loadRequest:fbRequestObj];
You might need to get familiar with Facebook's Graph Api
Go through this -> https://developers.facebook.com/docs/mobile/ios/build/

Resources