How to get videoId when video is uploaded on Vimeo - c#

How do I get the videoId after a video is uploaded on vimeo? When we call delete upload ticket, we have confirmed that the upload is successful and we are getting a response url like this url=https://api.vimeo.com/users/111243975/uploads/319650191?video_file_id=1786656414&upgrade=true&signature=4c02359068ec5a31cea3b633f6b5f9cf. Here we have video_file_id but not the actual videoId.

You're using a deprecated upload method (the "resumable" PUT method), so its documentation is no longer available on the Vimeo Developer Site. Luckily, the Internet Archive has those docs saved.
After you make the final DELETE call to that endpoint, the video uri is returned in the location header of the response.

Pow, Brow, its correct!
Location: /videos/555380765
{Connection: keep-alive
Server: nginx
Cache-Control: no-store, no-cache, private
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Location: /videos/555380765
X-RateLimit-Limit: 500
X-RateLimit-Remaining: 499
X-RateLimit-Reset: 2021-05-26T19:57:59+00:00
Request-Hash: 2461d148
X-BApp-Server: api-v10808-f5ldq
X-Vimeo-DC: ge
Accept-Ranges: bytes
Via: 1.1 varnish, 1.1 varnish
Date: Wed, 26 May 2021 19:57:00 GMT
X-Served-By: cache-bwi5155-BWI, cache-cgh11141-CGH
X-Cache: MISS, MISS
X-Cache-Hits: 0, 0
X-Timer: S1622059020.784666,VS0,VE594
Vary: Accept, Vimeo-Client-Id
Content-Length: 0
Content-Type: text/html; charset=UTF-8
}

Related

400-Bad request- request header to long

I'm trying to generate pdf,but after like the 5th page header and footer display http error 400-bad request-request header to long. is there anyway to solve this problem? a response header can look like
this
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: // i hid the adress
Cache-Control: no-store, no-cache
Content-Disposition: attachment; filename=Utskrift.pdf
Content-Length: 162568
Content-Type: application/pdf
Date: Tue, 25 Oct 2022 08:57:16 GMT
Expires: -1
Pragma: no-cache
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
The length you are trying to send is very large to be handled. It is like overdosing the request header. What you can do is, you can consider to break it in to chunks (smaller sizes), and send them separately until you gather all the file size on the endpoint you are sending.

Twitter API, Tweets with Images, Error Code 324 "The validation of media ids failed."

I have been able to successfully post status updates with images attached. I am using C#/.NET with a REST framework called Hammock. First, I upload the images to upload.twitter.com/1.1/media/upload.json and get media_ids back. Then, I make a request to api.twitter.com/1.1/statuses/update.json with the media_ids parameter. This works fine except that occassionally, with larger images, Twitter responds to my status update request with the following JSON:
{"errors":[{"code":324,"message":"The validation of media ids failed."}]}
I have tried waiting several minutes between the time of media upload and status update with no success. I have also posted on Twitter's developer forums, but posting here as well in case anyone has experienced this and has any insight. https://twittercommunity.com/t/the-validation-of-media-ids-failed-error-code-324/29304 I don't see "324" anywhere in Twitter's API documentation, especially here: https://dev.twitter.com/overview/api/response-codes
Here are the exact (except for sensitive values being xxxx'd out) requests/responses seen in Fiddler:
Media Upload Request
POST https://upload.twitter.com/1.1/media/upload.json HTTP/1.1
Authorization: OAuth oauth_consumer_key="xxxxxxxxxxx",oauth_nonce="xxxxxxxxxxx",oauth_signature="xxxxxxxxx",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1418763417",oauth_token="xxxxxxxxxx",oauth_version="1.0a"
Content-Type: multipart/form-data; boundary=5fb9e9e7-25cf-49fd-b5ef-61aefed2897e
Host: upload.twitter.com
Content-Length: 2399916
--5fb9e9e7-25cf-49fd-b5ef-61aefed2897e
Content-Disposition: form-data; name="media"; filename="d1cd395d-bebf-4733-aedc-680327ef63ec"
Content-Type: image/jpeg
Media Upload Response
HTTP/1.1 200 OK
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
content-length: 140
content-type: application/json;charset=utf-8
date: Tue, 16 Dec 2014 20:56:57 UTC
expires: Tue, 31 Mar 1981 05:00:00 GMT
expires: Tue, 16 Dec 2014 21:56:57 GMT
last-modified: Tue, 16 Dec 2014 20:56:57 GMT
pragma: no-cache
server: tsa_b
set-cookie: lang=en
set-cookie: guest_id=v1%xxxxxxxx; Domain=.twitter.com; Path=/; Expires=Thu, 15-Dec-2016 20:56:57 UTC
status: 200 OK
strict-transport-security: max-age=631138519
x-access-level: read-write
x-connection-hash: xxxxxxxxxxx
x-frame-options: SAMEORIGIN
x-response-time: 344
x-transaction: xxxxxxxxx
x-xss-protection: 1; mode=block
{"media_id":544959385899122689,"media_id_string":"544959385899122689","size":4311817,"image":{"w":3000,"h":2350,"image_type":"image\/jpeg"}}
Status Update Request
POST https://api.twitter.com/1.1/statuses/update.json HTTP/1.1
Authorization: OAuth oauth_consumer_key="xxxxxxxxxx",oauth_nonce="xxxxx",oauth_signature="xxxxxxxxxxxx",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1418763469",oauth_token="xxxxxxxxxxx",oauth_version="1.0a"
Content-Type: application/x-www-form-urlencoded
Host: api.twitter.com
Content-Length: 117
status=test%20test%20test&media_ids=544959385899122689%2C544959443889557504%2C544959458036957184%2C544959545941192705
Status Update Response
HTTP/1.1 400 Bad Request
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
content-length: 73
content-type: application/json;charset=utf-8
date: Tue, 16 Dec 2014 20:57:49 UTC
expires: Tue, 31 Mar 1981 05:00:00 GMT
last-modified: Tue, 16 Dec 2014 20:57:49 GMT
pragma: no-cache
server: tsa_b
set-cookie: lang=en
set-cookie: guest_id=xxxxxx; Domain=.twitter.com; Path=/; Expires=Thu, 15-Dec-2016 20:57:49 UTC
status: 400 Bad Request
strict-transport-security: max-age=631138519
x-access-level: read-write
x-connection-hash: xxxxxxxx
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-response-time: 44
x-transaction: xxxxxxx
x-xss-protection: 1; mode=block
{"errors":[{"code":324,"message":"The validation of media ids failed."}]}
This is a result of the image being too large. I just ran in to the same issue, and resolved it by sending along a jpg version (300KB) of a largeish png (it was 1.2MB).
The stated size limit is 3MB, but they might have some kind of client-specific throttling in place.

Google contacts api (gdata) syncs low resolution photos

I'm using google contacts api (gdata) to set a contact's photo in google contacts.
I'm using fiddler and I see that the request is sent according to Google Contacts Examples but the photo downloaded back from google is always 96x96.
The code I'm using to update and download the photo is:
public void UpdateUserPhoto(Contact contact, Stream photo)
{
_contactsRequest.SetPhoto(contact, photo);
}
public static void DownloadPhoto(ContactsRequest cr, Contact contact)
{
if (contact.PhotoEtag == null)
return;
Stream photoStream = cr.Service.Query(contact.PhotoUri);
FileStream outStream = File.OpenWrite(string.Format(#"c:\friends\{0}.jpg",contact.Name.FullName));
byte[] buffer;
using (var memoryStream = new MemoryStream())
{
photoStream.CopyTo(memoryStream);
buffer = memoryStream.ToArray();
}
outStream.Write(buffer, 0, buffer.Length);
photoStream.Close();
outStream.Close();
}
I tried syncing the contacts to my phone and there too, the size was always limited to 96x96.
Am I doing something wrong or does google not allow syncing more than 96x96? I can see many apps that do sync contacts with more than 96x96 then I guess it's possible, but what is the right way?
Edit
Here are the sync & retrieval of the photo as captured by fiddler:
Sync photo request:
PUT https://www.google.com/m8/feeds/photos/media/mymail#gmail.com/55f3484e8aaf1c82 HTTP/1.1
Etag: "SomeEtag"
If-Match: "SomeEtag."
Content-Type: image/jpg
User-Agent: G-GoogleContactsSync/GOAuth2RequestFactory-CS-Version=2.2.0.0
Authorization: Bearer myAuthorization
GData-Version: 3.0
Host: www.google.com
Content-Length: 34480
Sync photo response
HTTP/1.1 200 OK
Content-Type: application/atom+xml; charset=UTF-8; type=entry
GData-Version: 3.1
ETag: "KgxxHGIyfCt7I2BoA047FShUNFU3BWx8RDQ."
Date: Wed, 01 Oct 2014 20:13:06 GMT
Expires: Wed, 01 Oct 2014 20:13:06 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alternate-Protocol: 443:quic,p=0.01
Content-Length: 694
(Here comes xml with Id, Updated, edited etc.)
Photo Request:
GET https://www.google.com/m8/feeds/photos/media/myMail#gmail.com/55f3484e8aaf1c82 HTTP/1.1
Content-Type: application/atom+xml; charset=UTF-8
User-Agent: G-GoogleContactsSync/GOAuth2RequestFactory-CS-Version=2.2.0.0
Authorization: Bearer myAuthorization
GData-Version: 3.0
Host: www.google.com
Photo Response:
HTTP/1.1 200 OK
Content-Type: image/jpeg
Expires: Wed, 01 Oct 2014 20:25:54 GMT
Date: Wed, 01 Oct 2014 20:25:54 GMT
Cache-Control: private, max-age=0, must-revalidate, no-transform
Vary: Accept, X-GData-Authorization, GData-Version
GData-Version: 3.1
ETag: "SomeEtag."
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alternate-Protocol: 443:quic,p=0.01
I retested this myself and uploaded pictures from a number of sources including contacts app on my android phone and tablet, the gmail contacts and the API. All of them will take a higher resolution picture but will only allow the size to be 96x96 using the Contact API v3.So when you download via any application using that API on the PC you will get a 96x96 image and there appears to be no way to vary that with that particular API.
Meaning unless I've also missed something that the contact API v3 is limited to this size of image. I suspect the google+ equivalents are not.
The way in which I have done this is to use the google plus api
var service = new PlusService(new BaseClientService.Initializer());
var request = new PeopleResource.GetRequest(service, "<your google user id>")
{
OauthToken = authParameters.AccessToken
};
Person person = request.Execute();
Person.ImageData image = person.Image;
string pictureUrl = image.Url;
... request to url here after munging sz
now you are going to need to change the url that comes back to the size you want as the defaults is ?sz=50, if your original is at the size you specify it will show it or otherwise it will scale the image.
However the contacts api and the google plus api are different beasts. You will need to use the domain functionality of google plus to pull out your contacts there and potentially they have different photos than you do in your contacts list (if any is set).
Krystan

oAuth 2.0 Google API asp.net Requesting Token

i have a problem getting token from google api, first i make this request to get code from google
accounts.google.com/o/oauth2/auth?scope=www.googleapis.com/auth/userinfo.profile www.googleapis.com/auth/userinfo.email&state=profile&redirect_uri={http://pedidostogo.com/Login.aspx}&response_type=code&client_id=519970867780.apps.googleusercontent.com&access_type=offline
this seems to be working fine (im getting a code from google) after that i make another request to get token using that code, for this i make:
accounts.google.com/o/oauth2/token?client_secret={my client secret}&grant_type=authorization_code&redirect_uri={http://pedidostogo.com/Login.aspx}&client_id={my client id}&code={code i get from google}
but when i do that POST request im getting:
Status:400 Bad Request
Headers: Pragma: no-cache
Date: Thu, 28 Feb 2013 20:00:00 GMT
Content-Encoding: gzip
X-Content-Type-Options: nosniff
Server: GSE
X-Frame-Options: SAMEORIGIN
Transfer-Encoding: chunked
Content-Type: application/json
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
X-XSS-Protection: 1; mode=block
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Data: {
"error" : "invalid_request"
}
can anyone tell me what im doing wrong? thanks.

Would like to get http response results like Fiddler

I'm trying to get the same type of results that Fiddler gets when I launch a webpage from my app.
Below is the code I'm using and the results I'm getting. I've used google.com only as an example.
What do I need to modify in my code to get the results I want or do I need an entirely different approach?
Thanks for your help.
My code:
// create the HttpWebRequest object
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create("http://www.google.com");
// get the response object which has the header info, using the GetResponse method
var objResults = objRequest.GetResponse();
// get the header count
int intCount = objResults.Headers.Count;
// loop through the results object
for (int i = 0; i < intCount; i++)
{
string strKey = objResults.Headers.GetKey(i);
string strValue = objResults.Headers.Get(i);
lblResults.Text += strKey + "<br />" + strValue + "</br /><br />";
}
My results:
Cache-Control
private, max-age=0
Content-Type
text/html; charset=ISO-8859-1
Date
Tue, 05 Jun 2012 17:40:38 GMT
Expires
-1
Set-Cookie
PREF=ID=526197b0260fd361:FF=0:TM=1338918038:LM=1338918038:S=gefqgwkuzuPJlO3G; expires=Thu, 05-Jun-2014 17:40:38 GMT; path=/; domain=.google.com,NID=60=CJbpzMe6uTKf58ty7rysqUFTW6GnsQHZ-Uat_cFf1AuayffFtJoFQSIwT5oSQKqQp5PSIYoYtBf_8oSGh_Xsk1YtE7Z834Qwn0A4Sw3ruVCA9v3f_UDYH4b4fAloFJbW; expires=Wed, 05-Dec-2012 17:40:38 GMT; path=/; domain=.google.com; HttpOnly
P3P
CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
Server
gws
X-XSS-Protection
1; mode=block
X-Frame-Options
SAMEORIGIN
Transfer-Encoding
chunked
=========================
Fiddler results:
Result Protocol Host URL Body Caching Content-Type Process Comments Custom
1 304 HTTP www.rolandgarros.com /images/misc/weather/P8.gif 0 max-age=700 Expires: Tue, 05 Jun 2012 17:53:40 GMT image/gif firefox:5456
2 200 HTTP www.google.com / 23,697 private, max-age=0 Expires: -1 text/html; charset=UTF-8 chrome:2324
3 304 HTTP www.rolandgarros.com /images/misc/weather/P9.gif 0 max-age=700 Expires: Tue, 05 Jun 2012 17:53:57 GMT image/gif firefox:5456
4 200 HTTP Tunnel to translate.googleapis.com:443 0 chrome:2324
5 200 HTTP www.google.com
The difference is Fiddler is actually recording an entire session, not just a single HTTP request.
If a user loads Google.com, the response is typically an HTML document which contains images, script files, CSS files, etc. Your browser will then initiate a new HTTP request for each one of those resources. With Fiddler running, it tracks each of those HTTP requests and spits out the result code and other information about the session.
With your C# code above, you're only initiating a single HTTP request, thus you only have information about a single result.
You'd probably be better off writing a browser plugin. Otherwise, you'd have to parse the HTML response and load other resources from that document as well.
If you do need to do this with C# code, you could probably parse the document with the HTML Agility Pack and then look for other resources within the HTML to simulate a browser. There's also embedded browsers, such as Awesomium, that might be helpful.
You are not asking for the same information that Fiddler is displaying. Fiddler shows the HTTP Status code, the host and URI and (it appears, from your example) the Content Length, Content Type and Cache status.
For many of these you will have to peek in to the response headers.

Categories

Resources