I'm looking for a sample as to how to send HTTP Basic-Auth header info as part of pdf submit via javascript.
I found the following sample javascript code from one of the iText pdf examples:
this.submitForm({
cURL:"http://itextpdf.com:8080/book/request",
cSubmitAs: "HTML"
});
Are there any other options to send HTTP username:password as part of the submitForm() method?
Thanks for your help.
I'm not an expert on using forms with PDFs, but from what I gather from the API documentation (page 345) and the responses on Adobe's help forum it doesn't look possible.
You may take a look into Net.HTTP.request though, that one does have an oAuthenticate argument (page 550 on the API 8.1 documentation or here for API 9.1) that would allow you to pass user and password for HTTP authentication or show a dialog where the user can type those in -- you can actually modify any HTTP header.
Performing a POST request that way with an appropriate oRequest would (probably) end up having the result you are looking for.
Note: Just realised the PDF I was citing is from SDK 8.1, SDK 9.1 doesn't show any authentication parameter for the submitForm method either though.
Related
I want to post "comment" on linkedin post(dynamic),I am using following url but i dont know which information should be pass for post comment on linkedin post ? How can i do this ?
I tried with following url
POST https://api.linkedin.com/rest/socialActions/{shareUrn|ugcPostUrn|commentUrn}/comments
You can find a description of the required URL parameters, and the expected request body, and a sample in the documentation here: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/comments-api?view=li-lms-2022-12&tabs=http#create-a-comment
When you click the "curl" tab of the sample, you'll also see the HTTP headers.
Since you tagged this as PHP, you'll first want to create an array representing the POST body and encode that with JSON. You can then use the builtin curl support or via a package like GuzzleHTTP to send the actual POST request. Alternatively, there are free and open-source packages that implement easy-to-use wrappers around the LinkedIn API for use in PHP.
I am searching for a way to trigger a custom Twitter Status update in JavaScript similar to how you can share on Facebook from pure JavaScript:
fb.ui({object to share}, function(response){//do stuff});
So far all I seem to find are examples that include launching a Twitter Status update from a DOM element without a callback of any kind. For my implementation, it is very important that I know that the Twitter status update was successful (HTTP 200).
Thanks in advance.
You ca do a simple ajax GET request on i.e. https://api.twitter.com/1.1/statuses/update.json?status=Maybe%20he%27ll%20finally%20find%20his%20keys.%20%23peterfalk
and then check the HTTP result of the ajax request. The request needs an oAuth access token and needs to be signed, look here
Probably there's no out-of-the-box solution but it should be quite easy to type these few lines.
I am developing an application that needs to gather information from GitHub, so I began looking at their API. My initial thought was to use the d3.json() function to get the data (because it's simple and has done good things for me in the past), but there doesn't appear to be a way for me to authenticate with that function. For example, $ curl -u "username" https://api.github.com is given as an example of basic authentication (from GitHub API--obviously they use curl for their examples).
So, is there a way to do authentication with the d3.json() function? And if not, what are my other options to get the JSON with JavaScript?
Thanks!
Edit:
I'm experimenting now with using jQuery's getJSON method as shown here, because I started getting the error "XMLHttpRequest cannot load url Origin url is not allowed by Access-Control-Allow-Origin." Of course, the switch doesn't help with the ability to authenticate, but I can at least get the public data (which is most).
Edit #2:
Has anyone experimented with michael/github or fitzgen/github-api? I'm going to start looking into those.
If you have a PHP script which echos JSON, you can do all authentication server-side. Note that you can also send a GET request to your PHP script, so the way you call your script can be dynamic.
I have web application where people can login from twitter and based on their preference and DOM events I need update their status on twitter. I have a good idea how to do this on server side, but for this project I am not using any server side code, So how can I do this by just javascript, #anywhere twitter api and twitter intents are taking me to no where because they prompt user for submitting the tweet which I dont want.
A pure Javascript solution to consume twitter API is not possible without compromising your consumer secret key. Twitter API authenticates every request using a HMAC-SHA1 token, the SHA1 token is generated using the public/private key assigned by twitter to your api account. If you plan to generate this token using a pure javascript SHA1 implementation then it means you will be exposing your private key in the javascript code which anyone can look at.
Even though technically its possible (provided you can find a javascript library which implements SHA1), its not advisable.
FYI, jQuery.Ajax method does let you modify the headers of the ajax request by tapping in to the beforeSend(jqXHR, settings) method.
You should be able to do this with an AJAX POST request to the REST API. Documentation: https://dev.twitter.com/docs/api/1/post/statuses/update
You target the URL http://api.twitter.com/1/statuses/update.format, where format can be either xml or json, and reflects the format of the response. Required data is the status text, and there are several optional parameters which I won't list here. This only works for the currently authenticated user.
An (untested) example using jQuery:
var message = "This is a tweet, there are many like it but this one is mine";
$.ajax({
type: "POST",
url: "http://api.twitter.com/1/statuses/update.json",
data: "status="+message,
datatype: "json"
});
I have a web service that performs a database search. It accepts both GET and POST requests, and can return data in either JSON, CSV, or HTML format based on the HTTP Accept header.
I have a web page that makes an Ajax request to this web service, and displays the search results.
I have been asked to add a button to this page that will allow the user to save the data in CSV format.
Earlier this year, someone was in the same boat, and got the response
You cannot do it using javascript
capabilities, since javascript has no
permission to write on client machine,
instead you can send request to server
to create csv file and send it back to
client.
So I added a button that does
window.open("MyWebService.cgi?" + theSameQueryStringIPassedInTheAjaxCall),
which opens the HTML version in a new browser tab. I want the CSV version. Is there a way I could pass an Accept: text/csv HTTP header? (I know how to do it with XMLHttpRequest and setRequestHeader, but that doesn't help me.)
Don't think so. I think you should use an parameter instead.