i'm trying to integrate some youtube features into my site. i am able to pull in my uploads. when i loop thru the results, i see the videos are NOT readonly.
however, when i go to update a video, i use the video feed for a specific video which returns readonly = TRUE!!
i'm using the same settings and request that i was using to pull in the upload feed, so i'm not sure why this isn't working.
when debugging, i am getting the video, but it is throwing a object refererence error on the .Update() line.
Dim settings As New YouTubeRequestSettings("exampleapp", BusinessLayer.Constants.YOUTUBE_DEV_KEY, Session("token"))
Dim ytRequest As New YouTubeRequest(settings)
Dim videoEntryUrl As String = "http://gdata.youtube.com/feeds/api/videos/" & litVideoId.Text
Dim v As Video = ytRequest.Retrieve(Of Video)(New Uri(videoEntryUrl))
If v IsNot Nothing Then
v.Title = txtTitle.Text.Trim
ytRequest.Update(Of Video)(v)
End If
Has anyone seen or dealt with this? Thoughts? Maybe i'm missing something?
Thanks!
I think you are getting object reference error because of the path. Please see my example below:
YouTubeRequestSettings settings = new YouTubeRequestSettings("NETUnittests", YTDeveloperKey, YTUser, YTPassword);
settings.Timeout = 10000000;
YouTubeRequest request = new YouTubeRequest(settings);
Google.YouTube.Video video = new Google.YouTube.Video();
//video.VideoId = lblVideoID.Text;
//http://gdata.youtube.com/feeds/api/users/USER_ID/uploads/VIDEO_ID
Uri videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/users/default/uploads/" + lblVideoID.Text); video = request.Retrieve<Google.YouTube.Video>(videoEntryUrl);
if (video.ReadOnly == false)
{
}
string tt = video.Title;
string dd = video.Description;
video.Title = tbTitle.Text;
video.Description = tbDescription.Text;
video.Keywords = tbKeywords.Text;
//video.Status.Value = "private";
request.Update(video);
Related
The code below works and will post to Twitter, but will only ever post one image to the account, even if three images are sent.
These are only jpg or png files, not video or animated gifs.
Any ideas would be appreciated.
Dim service = New TwitterService(key, secret)
service.AuthenticateWith(token, tokenSecret)
Dim opt As New SendTweetWithMediaOptions
Dim images As New Dictionary(Of String, IO.Stream)
Dim myStream As FileStream
If Len(ImgName1) > 0 Then
myStream = New FileStream(ImgName1, FileMode.Open)
images.Add("1", myStream)
End If
If Len(ImgName2) > 0 Then
myStream = New FileStream(ImgName2, FileMode.Open)
images.Add("2", myStream)
End If
If Len(ImgName3) > 0 Then
myStream = New FileStream(ImgName3, FileMode.Open)
images.Add("3", myStream)
End If
opt.Status = TweetText
opt.Images = images
Dim TwitterStatus = service.SendTweetWithMedia(opt)
The code I used to get it working using TweetInvi https://github.com/linvi/tweetinvi (installed via Nuget) is:
(Imports Tweetinvi)
Auth.SetUserCredentials(key, secret, token, tokenSecret)
Dim params As New Tweetinvi.Parameters.PublishTweetOptionalParameters()
params.Medias = New List(Of Models.IMedia)
Dim MediaIDs As String = String.Empty
Dim ids As New List(Of Long)
If Len(ImgName1) > 0 Then
Dim imgFile1 As Byte() = System.IO.File.ReadAllBytes(ImgName1)
Dim myMedia1 = Upload.UploadImage(imgFile1)
ids.Add(myMedia1.MediaId)
imgFile1 = Nothing
End If
If Len(ImgName2) > 0 Then
Dim imgFile2 As Byte() = System.IO.File.ReadAllBytes(ImgName2)
Dim myMedia2 = Upload.UploadImage(imgFile2)
ids.Add(myMedia2.MediaId)
imgFile2 = Nothing
End If
If Len(ImgName3) > 0 Then
Dim imgFile3 As Byte() = System.IO.File.ReadAllBytes(ImgName3)
Dim myMedia3 = Upload.UploadImage(imgFile3)
ids.Add(myMedia3.MediaId)
imgFile3 = Nothing
End If
params.MediaIds = ids
Dim myTweet = Tweet.PublishTweet("blah, blah, blah", params)
The API end point called by that TweetSharp method doesn't support multiple images (I don't think it ever did, but either way the current docs say no; https://dev.twitter.com/rest/reference/post/statuses/update_with_media).
What you need to do is use the UploadMedia endpoint to upload the image and capture the id for each, then send a tweet with the list of ids.
I'm not sure which variant of TweetSharp you're using. The official/original one has known bugs in the Nuget package, and while the source in the repo has those fixed it is lacking the newer API support.
You could try TweetMoaSharp (mostly maintained by me), as I believe this supports the new end points (but it's been a while since I looked). There's also tweetsharp-alternative on Nuget and a few others floating around that might have support.
I am using the below code to get the Title and description of the youtube video embeded in my asp.net application. I am able to see the Title, but not description.
I use Atomfeed to do this...
Problem is i get the Description as "Google.GData.Client.AtomTextConstruct" for all my videos.
Private Function GetTitle(ByVal myFeed As AtomFeed) As String
Dim strTitle As String = ""
For Each entry As AtomEntry In myFeed.Entries
strTitle = entry.Title.Text
Next
Return strTitle
End Function
Private Function GetDesc(ByVal myFeed As AtomFeed) As String
Dim strDesc As String = ""
For Each entry As AtomEntry In myFeed.Entries
strDesc = entry.Summary.ToString()
Next
Return strDesc
End Function
I believe that when the XML from the atom feed is parsed, that the description is not handled. Take a look at this: http://code.google.com/p/google-gdata/wiki/UnderstandingTheUnknown
But what happens with things that are not understood? They end up as
an element of the ExtensionElements collection, that is a member of
all classes inherited from AtomBase, like AtomFeed, AtomEntry,
EventEntry etc...
So, what we can do is pull out the description from the extensionelement like this:
Dim query As New FeedQuery()
Dim service As New Service()
query.Uri = New Uri("https://gdata.youtube.com/feeds/api/standardfeeds/top_rated")
Dim myFeed As AtomFeed = service.Query(query)
For Each entry In myFeed.Entries
For Each obj As Object In entry.ExtensionElements
If TypeOf obj Is XmlExtension Then
Dim xel As XElement = XElement.Parse(TryCast(obj, XmlExtension).Node.OuterXml)
If xel.Name = "{http://search.yahoo.com/mrss/}group" Then
Dim descNode = xel.Descendants("{http://search.yahoo.com/mrss/}description").FirstOrDefault()
If descNode IsNot Nothing Then
Console.WriteLine(descNode.Value)
End If
Exit For
End If
End If
Next
Next
Also, the reason why you are getting "Google.GData.Client.AtomTextConstruct" is because Summary is an object of type Google.GData.Client.AtomTextConstruct, so doing entry.Summary.ToString() is just giving you the default ToString() behavior. You would normally do Summary.Text, but this of course is blank because as I say above, it's not handled properly by the library.
For youtube, I fetch the information for each video using the Google.GData.YouTube.
Something like this returns a lot of information from the video.
Dim yv As Google.YouTube.Video
url = New Uri("http://gdata.youtube.com/feeds/api/videos/" & video.Custom)
r = New YouTubeRequest(New YouTubeRequestSettings("??", "??"))
yv = r.Retrieve(Of Video)(url)
Then it's possible to get the description with: yv.Description
I am facing an issue while trying to fetch data from GoogleAnalytics API on piece of code that has been working well just a couple of days ago.
For this I am referencing the following DLL's:
Google.GData.Analytics.dll
Google.GData.Client.dll
Google.GData.Extensions.dll
And I am using the following code:
Dim visits As String = String.Empty
Dim username As String = "myuser#mydomain.com"
Dim pass As String = "mypassword"
Const dataFeedUrl As String = "https://www.google.com/analytics/feeds/data"
Dim query As AccountQuery = New AccountQuery()
Dim service As AnalyticsService = New AnalyticsService("MyWebAnalyticsService")
service.setUserCredentials(username, pass)
Dim accountFeed As AccountFeed = service.Query(query) ''----------> Exception thrown in this line: GDataRequestException Execution of request failed: https://www.google.com/analytics/feeds/accounts/default
I thought it had to do with a blocking to the account I was using but it wasn't the case because I verified registering the site for another analytics account and is still not working.
This code has been working flawlessly as I've said but all of a sudden has stopped doing so yesterday.
Could you please help me figuring out what's wrong?. Maybe the way the user credentials are set has changed and I am missing something.
Thank you very much for your help.
'----Update----
I managed to make it work and now I can query the visits for a desired domain. The code goes as follows:
Dim visits As String = String.Empty
Dim username As String = "myuser#mydomain.com"
Dim pass As String = "mypassword"
'Follow the instructions on https://developers.google.com/analytics/resources/articles/gdata-migration-guide (Create a Project in the Google APIs Console) to generate your key
'Once you have it set it as part of the querystring to request our GA service
Dim gkey As String = "key=yourkeystring"
'Set the new URI to retrieve the feed data and append it the generated key
Dim dataFeedUrl As String = "https://www.google.com/analytics/feeds/data?" & gkey
'Create and authenticate on our service instance
Dim service As AnalyticsService = New AnalyticsService("MyAnaliticsService")
service.setUserCredentials(username, pass)
'Use the profile id for the account you want to get ths visits from, you can find it
'logging in your analytics account, select the desired domain on your list (blue link)
click on the administrator button and on the profiles tab find the profile
'configuration subtab, right there you will find the profile id in this case the eight characters long id 12345678
Dim query1 As DataQuery = New DataQuery(dataFeedUrl)
With query1
.Ids = "ga:12345678"
.Metrics = "ga:visits"
.Sort = "ga:visits"
.GAStartDate = DateTime.Now.AddMonths(-1).AddDays(-2).ToString("yyyy-MM-dd")
.GAEndDate = DateTime.Now.ToString("yyyy-MM-dd")
.StartIndex = 1
End With
'Use the generated datafeed based on the former query to get the visits
Dim dataFeedVisits As DataFeed = service.Query(query1)
For Each entry As DataEntry In dataFeedVisits.Entries
Dim st As String = entry.Title.Text
Dim ss As String = entry.Metrics(0).Value
visits = ss
Next
I have the same problem and it looks like google recently shut down the feed. It is answered in another post. Issue com.google.gdata.util.ResourceNotFoundException: Not Found with Google Analytic
Please make sure you registered your project in the APIs Console and you are sending the API Key with your requests.
If that is not the issue, inspecting the inner exception will give you more details about the error. As an alternative, you can use Fiddler to capture the HTTP request and the response. The latter will include a more descriptive error message.
Hey I am currently using the following code
Dim flickr As New Flickr("apikey")
Dim test As New Photos
test = flickr.PhotosGetRecent(5, 5)
For Each [Photo] As FlickrNet.Photo In test.PhotoCollection
Response.Write([Photo].ThumbnailUrl)
Response.Write("<br>")
Next
But this only returns the Most Recent photos uploaded to flick in General, I only want my own ones. Is this possible ?
Thanks
Yes. You have you use PhotosSearch instead, and sort by DateUploaded.
Dim flickr As New Flickr("apikey")
Dim options As New PhotoSearchOptions()
options.UserId = "myuserid#n01"
o.SortOrder = PhotoSearchSortOrder.DatePostedDescending
o.PerPage = 5
o.Page = 1
Dim test As Photos = flickr.PhotosSearch(options)
... etc
I'm looking for a little help on programmatically passing parameters to a SSRS report via VB.NET and ASP.NET. This seems like it should be a relatively simple thing to do, but I haven't had much luck finding help on this.
Does anyone have any suggestions on where to go to get help with this, or perhaps even some sample code?
Thanks.
You can do the following,: (it works both on local reports as in Full Blown SSRS reports. but in full mode, use the appropriate class, the parameter part remains the same)
LocalReport myReport = new LocalReport();
myReport.ReportPath = Server.MapPath("~/Path/To/Report.rdlc");
ReportParameter myParam = new ReportParameter("ParamName", "ParamValue");
myReport.SetParameters(new ReportParameter[] { myParam });
// more code here to render report
If the Report server is directly accessible, you can pass parameters in the Querystring if you are accessing the repoort with a URL:
http://MyServer/ReportServer/?MyReport&rs:Command=Render&Param1=54321&Param2=product
You can add output formatting by adding the following on the end of the URL:
&rs:Format=Excel
or
&rs:Format=PDF
It's been a while since I did this code, but it may help:
Your web project has to be a Web Site, and not a project of type "ASP.Net Web Application", or you won't be able to add the reference mentioned below.
Right click on the project and add an ASP.Net folder - App_WebReferences. You'll have to specify the server where your SRS is; choose the .asmx.
Once it's added, the folder under that level is called RSService, and under that are 2 things: reportservice.discomap & .wsdl.
In my VB, I do Imports RSService and Imports System.Web.Services.Protocols, then...
Dim MyRS As New ReportingService
The reporting service is on a different server than the webserver the app is on, so I can't do the following: MyRS.Credentials = System.Net.CredentialCache.DefaultCredentials
Instead: MyRS.Credentials = New System.Net.NetworkCredential(rs1, rs2, rs3),
where the rs1/2/3 are the login to SRS box, password to SRS box, & domain name". (These are encrypted in my web.config.)
Then, a mass-paste:
MyRS.Credentials = New System.Net.NetworkCredential(rs1, rs2, rs3)
Dim ReportByteArray As Byte() = Nothing
Dim ReportPath As String = "/SRSSiteSubFolder/ReportNameWithoutRDLExtension"
Dim ReportFormat As String = "PDF"
Dim HistoryID As String = Nothing
Dim DevInfo As String = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"
'Dim x As ReportParameter - not necessary
Dim ReportParams(0) As ParameterValue
ReportParams(0) = New ParameterValue()
ReportParams(0).Name = "TheParamName"
ReportParams(0).Value = WhateverValue
Dim Credentials As DataSourceCredentials() = Nothing
Dim ShowHideToggle As String = Nothing
Dim Encoding As String
Dim MimeType As String
Dim ReportHistoryParameters As ParameterValue() = Nothing
Dim Warnings As Warning() = Nothing
Dim StreamIDs As String() = Nothing
'Dim sh As New SessionHeader() - not necessary
''MyRS.SessionHeaderValue = sh - not necessary
ReportByteArray = MyRS.Render(ReportPath, ReportFormat, HistoryID, DevInfo, ReportParams, Credentials, _
ShowHideToggle, Encoding, MimeType, ReportHistoryParameters, Warnings, StreamIDs)
'(Yay! That line was giving "HTTP error 401 - Unauthorized", until I set the credentials
' as above, as explained by http://www.odetocode.com/Articles/216.aspx.)
'Write the contents of the report to a PDF file:
Dim fs As FileStream = File.Create(FullReportPath, ReportByteArray.Length)
fs.Write(ReportByteArray, 0, ReportByteArray.Length)
fs.Close()
Call EmailTheReport(FullReportPath)
If IO.File.Exists(FullReportPath) Then
IO.File.Delete(FullReportPath)
End If
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.Reset();
Label1.Visible = false;
ReportViewer1.Visible = true;
DataSet dataSet = new DataSet();
dataSet = new ClassBLL().Load_Report_Detail(TextBox1.Text,
ddlType.SelectedValue, levelcode, fields);
ReportDataSource datasource = new ReportDataSource("DataSet_StoreprocedureName",
dataSet.Tables[0]);
if (dataSet.Tables[0].Rows.Count == 0)
{
ReportViewer1.Visible = false;
}
ReportViewer1.LocalReport.ReportPath = Server.MapPath("") + #"\Report.rdlc";
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource);
string fields="name,girish,Z0117";
string[] filedName = fields.Split(',');
ReportParameter[] param = new ReportParameter[2];
//for (int i = 0; i < filedName.Length; i++)
//{
param[0] = new ReportParameter(filedName[0], filedName[0], true);
param[1] = new ReportParameter(filedName[3], filedName[3], true);
// }
ReportViewer1.LocalReport.SetParameters(param);
ReportViewer1.ServerReport.Refresh();