Unable to post comment on linkedin via API - javascript

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.

Related

How to get link url from content that i publish

i'm using native php & mysql, creating content using tinymce.
how to get the link url from each post that i'm publish?
for example my base link is localhost/web
i have a content with title tes link url is localhost/web/tes
Consider using a router class + pretty URL or a framework...
For native php start with structure such as switch case and match url within case. Either way you need to understand how to handle properly a request / response. What comes from client (usually a browser) is the request and what gets out of the http server is a response. Read about HTTP protocol very very important! Look at the request and response structure in order to understand how you can build yours. Look at the PHP $_POST and $_GET arrays for request data... for a secure application you've to filter input and escape output. There are plenty of info about this topic. Also take in consideration sql injection! I'm sorry but your question is a simple hard one!
Start to read a LOT
So: You can put a <a>link</a>tag like this: link on your buttons!

Send HTTP Basic-Auth header info while submitting pdf to webserver

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.

Does d3.json() support authentication? If not, what other JavaScript options are available for JSON retrieval?

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.

jQuery send values through POST

I'm trying to implement a third party tool. This tool uses a form with the post method to send data to their site. Is there any way that I can mimic this action without using the form tag? I don't know much about jquery post and same domain (this is sending it off to a different domain) so I don't know if there would be an issue with this.
Everything that I've found in my search talks about ajax and returning content after you post but all I want to do is to take the customer to the third party's site after they have submitted the form.
thanks!
You cannot send data to a different domain with AJAX. Its not permitted by the browser. As for can you do it without a form element, yes. Just encode the data as it would look in a browser get URL like http://site.com/search?query=I+love+js&perpage=10&page=2
datatosend="field1="+value+"&field2="+value2
$.post(url,datatosend,function(data){//do something with data. location.href="new location"}
Yes you can.
Check out this post.
https://stackoverflow.com/a/1078991
also found in the docs
http://api.jquery.com/jQuery.post/
http://api.jquery.com/jQuery.post/
and then you can do a location.replace() when it is completed
function replaceDoc()
{
window.location.replace("http://www.thatsite.com")
}

Update twitter status without prompting user using pure JavaScript

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"
});

Categories