Using the Youtube Data API and the AP crashed - youtube-api

I have downloaded the sample code of the below path
http://www.codeproject.com/Articles/143669/Manage-YouTube-using-C-and-Youtube-API-1-6
Then I have installed the YouTube_SDK_2.1.0.0.msi
Now I can build the project successfully, but when I want to search a video in the Youtube
the AtomFeed of the videofeed will return the Error=NoLinkedYouTubeAccount
Please tell me what happened, I already surveyed some days in network.
Sample code list as below
yousettings = new YouTubeRequestSettings("My AP", devkey, username, password);
yousettings.Credentials.AccountType = "GOOGLE";
.........
videofeed = yourequest.Get<Video>(new Uri(feedUrl));
videofeed will always return fail then the Sample Ap will be crashed, the crash info list as below:
An unhandled exception of type
Google.GData.Client.GDataRequestException occurred in
Google.GData.Client.dll Additional information: Execution of request
failed:
http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?time=today
Note:
I have link the Youtube account to the Google account.
I try to modify the yousettings.Credentials.AccountType = "GOOGLE";
FeedUri = "http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?time=today"

Related

Migration from AlchemyNews to Watson Discovery gives 401 error in Swift V3 com.ibm.watson.developer-cloud.DiscoveryV1 Code=401

Hello I have moved over from AlchemyAPI to DiscoveryV1 but my swift program is getting a 401 error, rror Domain=com.ibm.watson.developer-cloud.DiscoveryV1 Code=401 "Not Authorized" UserInfo={NSLocalizedFailureReason=Not Authorized}
The app was working fine before moving to Discovery and the Bluemix support team have verified the credentials and get no error when running the query in BLuemix
for the sake of it I also added the url into the App transport Security settings which was a guess but it didn't change the error I have added a a screen capture of the App Transport settings
here are the credentials I am using
let wdn = Discovery(username: "my-user-name",
password: "my-password",
version: "2017-03-08")
let environmentID = "envID generated under my account on bluemix"
let collectionID = "collectionID generated under my account on bluemix"
let filter = ""
let query = newsSearchString < variable set later
let aggregation = "term(enriched_text.concepts.text).top_hits(10)"
let numberOfItemsToReturn = 30
let failure = { (error: Error) in print(error) }
let returnEntities = "enriched.url.url,enriched.url.title,enriched.url.author"
[enter image description here][1]
[1]: https://i.stack.imgur.com/5UvJO.png
I created a new app + service, and did not get an unauthorized error. Here are the steps I followed:
I downloaded the Watson Conversation starter from Bluemix. This includes a lightweight Watson project which includes the SDKs and settings necessary to get set up quickly (essentially all you have to do is put your credentials in a config file for the Converation service).
Because that starter has all of the Watson configuration set up, I just imported the DiscoveryV1 service, dragged the Framework over to my project (updated the Build Phase), and typed in the initialization snippet and everything is working for me.

How to get token_for_business for Facebook login - iOS

How can I get token_for_business from Facebook login? I have setup a business and associated my application with that business. Facebook documentation says you need to call GET /me?fields=token_for_business on User node, and it will return following json.
{
"id": "1234567890"
"token_for_business": "weg23ro87gfewblwjef"
}
I tried by providing token_for_business in parameter list of /me call but didn't work. Need advises.
Edit
I found this URL https://developers.facebook.com/docs/graph-api/reference/v2.5/user and tried by passing token_for_business in param of initWithGraphPath but no gain. I checked in Graph API Explorer and getting the required data. But not sure how to call from my objective-C code.
Edit 2
I Inspected the error object of initWithGraphPath:#"me?fields=token_for_business" call and found following details
Error Domain=com.facebook.sdk.core Code=8 "(null)" UserInfo={com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=0, com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=403, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=(#200) Application must be associated with a business. https://business.facebook.com/, com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=200, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={
body = {
error = {
code = 200;
"fbtrace_id" = "EN9bN/YMloA";
message = "(#200) Application must be associated with a business. https://business.facebook.com/";
type = OAuthException;
};
};
code = 403;
}}
But if I try my app in Graph API Explorer then I'm getting the required data. So now it confusing me.

How do I use the YouTube Data API in my iOS app? I get "Access not configured" error on each request

I want to use the YouTube Data API to get the links to thumbnails for a specific YouTube video in my iOS app. I went to Google Developers Console and created a new project.
For that project I then went to "APIs" and removed the default APIs it enables for me and added the YouTube Data API. I then went to credentials, created a Public Key (as I don't need the user to log in or anything, just getting the thumbnail URLs) as iOS, which gave me an API key. I added the Bundle Identifier for my project under Allowed Applications.
Now in my app I tried the following code:
let test = NSURLSession.sharedSession().dataTaskWithURL(NSURL(string: "https://www.googleapis.com/youtube/v3/videos?id=7lCDEYXw3mM&key=*MYKEYHERE*&part=snippet,contentDetails,statistics,status")!, completionHandler: { (data, response, error) -> Void in
let json = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: nil)
println("JSON: \(json)")
})
But it prints out the error:
JSON: Optional({
error = {
code = 403;
errors = (
{
domain = usageLimits;
message = "Access Not Configured. Please use Google Developers Console to activate the API for your project.";
reason = accessNotConfigured;
}
);
message = "Access Not Configured. Please use Google Developers Console to activate the API for your project.";
};
})
What exactly am I doing wrong?
There is a known problem about Bundle id in the console. If you can just remove that restriction, it should just work fine.
You can track the original issue from here: https://code.google.com/p/gdata-issues/issues/detail?id=5770
Here's what you need, YouTube has a service API via web to consult this types of things. I'm using this URL to consult all videos from a user (getting every videos: URL, Thumbnail, views, duration, etc). I'm sure you'll find thumbnails for a particular video. Its a JSON response so you'll have to take a good look to the structure but can't get simpler than this.
http://gdata.youtube.com/feeds/api/users/USER_NAME/uploads?v=2&alt=json&#&start-index=1&max-results=10

Connection reset by peer + browser based upload youtube video

I'm trying to do Browser-based upload from android. In the first steps, the mobile asks my server to get a url and token from youtube. after the mobile got if from the server, the mobile uploads the video to youtube. But sometimes a "Connection Reset By Peer" exception is thrown, after the video was uploaded and can be seen on youtube. How can I avoid this error, or at least check if the video was uploaded correctly?
and another thing, I don't get the youtube_VideoId in the response (in the case there is no exception).
this is the code for the uploading step:
File file = new File(fileName);
try {
HttpClient client = new DefaultHttpClient();
String postURL = url + "?nexturl=http://example.com";
HttpPost post = new HttpPost(postURL);
FileBody bin = new FileBody(file);
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
reqEntity.addPart("email", new StringBody("XXX#gmail.com", "text/plain", Charset.forName("UTF-8")));
reqEntity.addPart("token", new StringBody(token));
reqEntity.addPart("uploadfile", bin);
this.totalSize = bin.getContentLength();
post.setEntity(reqEntity);
HttpResponse response = client.execute(post);
HttpEntity resEntity = response.getEntity();
Connection reset maybe a happening if there are really long videos. I know there was a bug open for more than an hour connections.
You can check YouTube direct Lite for Android project to poll about video status and processing status.

Facebook permissions to know if a friend uses the same app

I can successfully grab a list of friends with this NSURL, using the permissions "publish_stream":
NSURL *friendsList = [NSURL URLWithString:#"https://graph.facebook.com/me/friends
However, when I try the same thing with an added field, as in this URL:
NSURL *friendsList = [NSURL URLWithString:#"https://graph.facebook.com/me/friends?fields=installed"];
I get an error:
error = {
code = 2500;
message = "An active access token must be used to query information about the current user.";
type = OAuthException;
};
So my question is what permissions should I be asking for to make the second URL work?
Bonus question: What URL param do I include to get a small profile pic come back in the same JSON object?
Thanks :)
According to the docs, you it Requires app access_token. However, playing with Graph API Explorer, I could get this info without this permission.
You can take a look at Graph API Explorer to test.
Also, the query on the above link returns the picture field, which will have an URL with the user picture.

Resources