I have been trying to post an attachment on Yammer using Yammer Javascript api. There is not much documentation available on Yammer regarding this. Can someone help me to achieve this.
Thanks.
Hopes this may help you to solve the issue,
You can use POST:/pending-attachments yammer API for posting the images in yammer.
But If you want to create yammer post with images, POST:/messages.json can be used with attaching files - attachment_N or pending_attachment_N as a multipart form field.
Use this link for info - Yammer message API
adding a sample code using JavaScript SDK -
let otherFormData = {
"group_id": groupId,
"body": message,
"og_url": postUrl,
"og_fetch": false,
"og_title": title,
"og_image": og_image,
"og_description": summary,
"og_object_type": og_object_type,
"direct_to_user_ids": []
};
let formData = new FormData();
formData.append("attachment1", imgData_Base64, AfileName);
for (let i in otherFormData) {
formData.append(i, otherFormData[i]);
}
window.yam.platform.request({
url: "messages.json",
method: "POST",
data: formData,
processData: false,
contentType: false,
type: 'POST',
dataType: 'json',
success: (response) => {
console.info("The request is successful. ", response);
},
error: (err) => {
console.info("There is an error in the request.", err);
}
});
Related
I want to send mail using zapier with mailchimp.
What I did:
In my webiste I put ajax request and add zapier webhook.
$.ajax({
url: "https://hooks.zapier.com/hooks/catch/xzyabc/", // this is zapier webhook
type: "POST",
data: zapierData,
success: function(result) {
console.log('Zapier Success: ', result);
},
errors: function(error) {
console.log('Zapier Error:', error);
}
});
What else I need to do please explain step by step if anybody knows ?
Thanks,
I'm doing a chatbot based project. I came across Chatbase and I wanted to implement chatbase to analyse the data more indept I get from my chatbot. However, I am confused as to how to write the post method to the chatbase api and keeps receiving error 405 or 400. I don't have much experience in writing ajax requests so most probably the problem might be with the format of the code. If anyone is willing to help me out, I would really appreciate it. Thanks
Code for reference:
function chatbaseInput() {
$.ajax({
type: "POST",
url: chatbaseURL,
contentType: "charset=utf-8",
dataType: "json",
headers: {
"Access-Control-Allow-Origin": "website link"
},
data: JSON.stringify({
api_key: "apikey",
type: "user",
user_id: "140012004300",
time_stamp: 1516765680000,
platform: "Website",
message: "Default Welcome Intent",
intent: "Welcome Intent",
version: "1.0"
}),
success: function (data) {
setResponse("Chatbase works!");
},
error: function () {
setResponse("Chatbase not working");
}
});
}
Chatbase requests are meant to be sent from your server, they do not accept calls from a browser (CORS is not enabled).
I did the exact same thing before I discovered the same as you. We now proxy our calls via the server.
Here is the link where they mention this:
https://discuss.api.ai/t/chatbase-integration-and-api-ai/9966/15
I am getting an error that i dont understand an cannot find any helpfull informations about:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https:*******' is therefore not allowed access. The response had HTTP status code 401.
function RecordTheCall()
{
var key = '*******************';
$.get( "https://api.plivo.com/v1/Account/"+key+"/Call/?status=live", function( data ) {
var callUuid = data.call_uuid
});
$.ajax({
url: "https://api.plivo.com/v1/Account/"+key+"/Call/"+callUuid+"/Record/",
type: "POST",
data: { 'auth_id': auth_id, 'call_uuid': CallUUID },
dataType: "json",
success: function (res) {
alert(res);
},
error: function(err) {
alert(err);
}
});
}
Call recording cannot be accomplished from the Web SDK directly. You cannot use the Plivo API from your Web browser using Javascript because cross-domain ajax requests are not allowed in browsers for security reasons.
This has been explained in this Wikipedia article. There are some work arounds to overcome this, but it is browser dependent and hence it might not work always. Instead you should use the Plivo XML/API in you application.
Thank you in advance for any assistance you maybe able to provide. I'm trying to post from my app to an app group that I have created. Using the code below it completes the request successfully but the data returned is empty. Please tell me what I'm doing wrong. I did also notice that it's not performing a POST but rather a GET.
$.ajax({
type: 'POST',
url: 'https://graph.facebook.com/v2.1/'+g_id+'/feed?access_token='+User["User AccessToken"],
data: JSON.stringify({
message: g_mes
}),
dataType: "jsonp",
success: function(data){
console.log(data);
},
error: function(data1){
console.log(data1);
}
})
You really should use the JavaScript SDK for the API. Here is a basic tutorial: https://developers.facebook.com/docs/javascript/quickstart/v2.1
And this is what the API call would look like:
FB.api('/' + g_id + '/feed', 'post', {message: g_mes}, function(response) {
console.log(response);
});
See Facebook docs for a code example too: https://developers.facebook.com/docs/graph-api/reference/v2.1/group/feed
You donĀ“t even need to worry about the Access Token. You just need to use FB.login with the appropriate permissions in the scope parameter to authorize the user.
Aim - to get the twitter followers of a particular user using javascript
I have tried the below code as a POC-
$(document).ready(function() {
// Handler for .ready() called.
$.ajax({
url: "https://api.twitter.com/1.1/followers/ids.json?callback=?",
type: "GET",
data: { cursor: "-1",
screen_name: "twitterapi" },
cache: false,
dataType: 'json',
success: function(data) { alert('hello!'); console.log(data);},
error: function(html) { alert(html); },
beforeSend: setHeader
});
function setHeader(xhr) {
if(xhr && xhr.overrideMimeType) {
xhr.overrideMimeType("application/j-son;charset=UTF-8");
}
//var nonce = freshNonce();
//var timestamp = freshTimestamp();
//var signature = sign(nonce,timestamp);
//alert(signature);
//alert(accessToken+"-"+consumerKey);
//alert(oauth_version+"-"+oauth_signature_method);
xhr.setRequestHeader('Authorization','OAuth');
xhr.setRequestHeader('oauth_consumer_key', 'HdFdA3C3pzTBzbHvPMPw');
xhr.setRequestHeader('oauth_nonce', '4148fa6e3dca3c3d22a8315dfb4ea5bb');
xhr.setRequestHeader('oauth_signature','uDZP2scUz6FUKwFie4FtCtJfdNE%3D');
xhr.setRequestHeader('oauth_signature_method', 'HMAC-SHA1');
xhr.setRequestHeader('oauth_timestamp', '1359955650');
xhr.setRequestHeader('oauth_token', '1127121421-aPHZHQ5BCUoqfHER2UYhQYUEm0zPEMr9xJYizXl');
xhr.setRequestHeader('oauth_version', '1.0');
}
});
I calculated the signature values from the Twitter OAuth tool ..
This gives me 400 Bad Request error ....
Please let me know what the problem is...
The problem is your request's header, it should be like this:
xhr.setRequestHeader('Authorization','OAuth oauth_consumer_key="HdFdA3C3pzTBzbHvPMPw", oauth_nonce="4148fa6e3dca3c3d22a8315dfb4ea5bb", oauth_signature="uDZP2scUz6FUKwFie4FtCtJfdNE%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp= "1359955650", oauth_token, "1127121421-aPHZHQ5BCUoqfHER2UYhQYUEm0zPEMr9xJYizXl", oauth_version="1.0"');
Btw, this javascript library might help you on OAuth's stuff: oauth-1.0a
It support both client side and node.js
Cheers
The oauth_* fields are all part of the Authorization header string, so they need to be concatenated as shown at the bottom of this page - https://dev.twitter.com/docs/auth/authorizing-request
They should not be presented as separate header fields.