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
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'm trying to generate a report and export it to pdf in a loop, the report will receive a new parameter in each loop and prompt the client to download a PDF, in other words, the client may need to download 2 or 3 (or more) PDFs at the same time, the problem is that the prompt to accept the download only appears for the first pdf, dont know why. I can export to disk (server side) without any problems.
Code:
Sub PrintReport(ByVal Cod As Integer)
Dim CTableLogInfo As TableLogOnInfo
Dim ConnInfo As CrystalDecisions.Shared.ConnectionInfo = New ConnectionInfo()
ConnInfo.Type = ConnectionInfoType.SQL
ConnInfo.ServerName = ConfigurationManager.AppSettings("SQLSERVERNAME")
ConnInfo.DatabaseName = ConfigurationManager.AppSettings("SQLDBNAME")
ConnInfo.UserID = ConfigurationManager.AppSettings("SQLSERVERUSER")
ConnInfo.Password = ConfigurationManager.AppSettings("SQLSERVERPASSWORD")
ConnInfo.AllowCustomConnection = False
ConnInfo.IntegratedSecurity = False
For Each CTable As Table In CrystalReportSource1.ReportDocument.Database.Tables
CTable.LogOnInfo.ConnectionInfo = ConnInfo
CTableLogInfo = CTable.LogOnInfo
CTableLogInfo.ReportName = CrystalReportSource1.ReportDocument.Name
CTableLogInfo.TableName = CTable.Name
CTable.ApplyLogOnInfo(CTableLogInfo)
Next
Dim pField As ParameterField = CrystalReportSource1.ReportDocument.ParameterFields(0)
Dim val1 As ParameterDiscreteValue = New ParameterDiscreteValue
val1.Value = Cod
pField.CurrentValues.Clear()
pField.CurrentValues.Add(val1)
Dim PDFName As String = "PDF Nº " & Cod
CrystalReportSource1.ReportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Page.Response, True, PDFName)
End Sub
EDIT:
Tried to zip the reports with DotNetZip but i get an broken zip.
Can you tell me whats wrong? (Solved: code bellow is corrected now)
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/zip"
Response.AppendHeader("content-disposition", "attachment; filename=AllPDFs.zip")
Using zipFile As New ZipFile()
For i = 0 To Cod.Length - 1
If Cod(i) > 0 Then
val1.Value = Cod(i)
pField.CurrentValues.Clear()
pField.CurrentValues.Add(val1)
val2.Value = Cod(i)
pField2.CurrentValues.Clear()
pField2.CurrentValues.Add(val2)
Dim PDFNameAs String = "PDF Nº " & Cod(i) & ".pdf"
Dim s As New System.IO.MemoryStream
s =CrystalReportSource1.ReportDocument.ExportToStream(ExportFormatType.PortableDocFormat)
zipFile.AddEntry(PDFName, s)
End If
Next
zipFile.Save(Response.OutputStream)
End Using
Response.Clear()
Probably the response ends after the first one, therefore there's no response to write to for the 2nd and 3rd attempts.
Instead, you can have the client download the reports via AJAX Request (move your report generation into an .ashx generic handler), or have the user click the button 3 times to initiate new requests.
Or zip the PDF's up until a single file and allow the client to download that.
I have the code of Jquery for link to the asp page as below:
Jquery code:
var url = "script_right2.asp?soc="+societe+"&phoneNum="+phoneNumber+"&seleDro="+sedro+"&desc="+des;
I want to get the value of societe,phoneNumber,seleDro,desc to the page script_right2.asp
But the problem is that I do not know how to get these data in asp page using vbscript.
I'm not sure what the question is so I'll answer it twice!
To replicate what you have using VBScript:
dim stringUrl
stringUrl = "script_right2.asp?soc=" & societe & "&phoneNum=" & phoneNumber & "&seleDro=" & sedro & "&desc=" & des;
Or, if you want to get the value of the variables from the query string you could do
dim soc
dim phone
dim sedro
dim desc
soc = Request.QueryString("soc")
phone = Request.QueryString("phoneNum")
sedro = Request.QueryString("seleDro")
desc = Request.QueryString("desc")
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);
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