How to programmatically subscribe a user to a google calendar using javascript? - javascript

Hey i'm able to authenticate and authorize a user with the javascript API for google calendar. what i want to do next is subscribe that user to a public calendar. I was thinking i could just call the google.gdata.calendar.CalendarEntry constructor with the id of the calendar but that didn't work
var entry = google.gdata.calendar.CalendarEntry("idOfCalendar");
i also tried creating an instance of a entry id with google.gdata.atom.Id("idOfCalendar"); and adding that to the CalendarEntry constructor. Using the set methods didn't work either.
I use the InsertEntry method to add the entry but i get the following error
Error: Valid calendar id must be supplied for adding calendar to favorites list in allcalendars projection.
I can access the events of this calendar using google.gdata.calendar.CalendarEventQuery()
The google api for javascript doesn't give a lot of examples anyone know the answer to my problem or a good resource for working with the google calendar api? do you think i should be using php or jason instead?
** Edit
I found an example of what I want in the Java Api link so i tried
function addSubscriptionToCalendar() {
var feedUri = "http://www.google.com/calendar/feeds/default/allcalendars/full";
var calendarEntry = new google.gdata.calendar.CalendarEntry();
calendarEntry.setId("nhl_21_%54oronto+%4daple+%4ceafs#sports#group.v.calendar.google.com");
calendarService.insertEntry(feedUri, calendarEntry, function(){alert("calendar added")}, handleError);
}
but i got the same error

You should be using owncalendars feed to modify/add calendar entry for the authenticated user not allcalendars.

Sounds like your calendar id is invalid. The id from your second example appears to be URL encoded. Try using the decoded value:
nhl_21_Toronto Maple Leafs#sports#group.v.calendar.google.com

The gdata API for calendars has been switched off; the new way to do this is via: https://developers.google.com/google-apps/calendar/v3/reference/calendarList/insert

Related

azure function service bus output message properties

I'm trying to set metadata for service bus messages in a JavaScript Azure Function using the service bus binding output. Unfortunately, it appears that the binding only supports the body.
Looking at the docs, I see that you can access this information in service bus triggers via context.bindingData but I don't see any corresponding interface for service bus output.
Is there some way to send a full brokered message and set the message properties (ContentType) and message custom properties?
#l--''''''---------'''''''''''' You need to access the Microsoft.Azure.ServiceBus.Message class. Let's say you have some json called messageBody
and you have some list of properties that you want to add to the message. You can achive it like the below example.
Make sure you add using Microsoft.Azure.ServiceBus;
var myCustomProperties = new List<Dictionary<string,string>>();
var message = new Message(Encoding.UTF8.GetBytes(messageBody));
foreach (var userProperty in myCustomProperties)
{
message.UserProperties.Add(userProperty.Key, userProperty.Value);
}
There is an open issue for this at https://github.com/Azure/Azure-Functions/issues/454
Some customers seemed to have found a workaround. Perhaps you can try their approach mentioned here https://github.com/Azure/Azure-Functions/issues/454#issuecomment-375154151

Create QuoteProduct in Dynamics CRM 2016 using new Web API and JavaScript POST

I am running into an issue setting the Existing Product field on a new Quote Product record in Microsoft Dynamics CRM 2016 on-prem using the new Web API.
I am following the 2016 SDK documentation to a T, and for the most part, all of my POST and GET requests are working. I am aware of using the #odata.bind syntax for setting lookups, however, while I CAN create a Quote Product entity setting the parent QuoteId with the GUID, for whatever reason, the POST will not complete when I try to set the productid value in the same manner as the quoteid.
Has anyone else been successful with this? I've looked over all of the values in in the CRM db for the QuoteDetail table and tried setting them all the same as existing records, but keep getting hung up on the productid.
Thanks for any help!
-James
This is the minimal post body that you need to create a quote product:
{
"productid#odata.bind": "/products(11c0dbad-91df-e311-b8e5-6c3be5a8b200)",
"quoteid#odata.bind" : "/quotes(69b5e1ae-037f-e611-80ed-fc15b428dcdc)",
"uomid#odata.bind" : "uoms(73a5daea-6ddc-e311-a678-6c3be5a8c0e8)"
}
And this is the url I'm using:
https://tenantname.api.crm.dynamics.com/api/data/v8.1/quotedetails
Please note that you wil get an error about missing quantities if you only use this post message body.
As #Martijin Eikelenboom pointed ot in his answer, you need to be sure to add the plural for unit of measure in your syntax when you specify the entity type; ie: {
"uomid#odata.bind" : "/uoms(GUID)"
}

Facebook PHP API How to get current user profile_id?

After login with FB JavaScript API, how can I get the profile_id of that user? ('/me'), please help...I used many hours on google and facebook official dev site still no luck on this. How come this kind of simple user profile id also didn't provide in API documentation...is me noob or facebook?.
sesssion_start();
require_once 'autoload.php';
use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\Entities\AccessToken;
use Facebook\HttpClients\FacebookCurlHttpClient;
use Facebook\HttpClients\FacebookHttpable;
use Facebook\FacebookJavaScriptLoginHelper;
FacebookSession::setDefaultApplication( 'APP_ID','APP_SECRET' );
$helper = new FacebookJavaScriptLoginHelper();
$session = new FacebookSession($_POST['access_token']);
$request = new FacebookRequest(
$session,
'GET',
'/me'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
$profile_id = $graphObject->getProperty('profile-id'); // HOW TO GET PROFILE ID??
P.S: I want profile id not user id...
I think You have to get user_id
A user represents a person on Facebook. The /{user-id} node returns a single user.
Here is the reference of Graph Api .. Check it in detail according to your requirement
https://developers.facebook.com/docs/graph-api/reference/user
For profile-id
check that link of Graph Api
Reference:
Profile /{profile-id}
A profile can be a:
User
Page
Group
Event
Application
The profile object is used within the Graph API to refer to the generic type that includes all of these other objects.
The individual reference docs for each profile type should be used instead.
Fields
When something has a profile, Graph API returns the fields for that object.
https://developers.facebook.com/docs/graph-api/reference/v2.5/profile/

get foreignId Data from the feed of a user [Stream Js]

hi i'm trying to implement getstream.io in my project.
i'm using https://github.com/GetStream/stream-js
as my server side script is in nodeJS.
i'm able to create a user in feed using
user1 = client.feed('user', 'dpz');
i'm creating activity for this user using using
activity ={
"actor":"user:1",
"message": "#flat_4_bfcaffca-c35f-11e5-8080-8001002e75f6",
"verb":"tweet",
"object":"tweet:4",
"foreign_id": "flat:4"
};
user1.addActivity(activity);
if i want to get all records of that user,
i use
user1.get()
.then(function(body) { console.log(JSON.stringify(body)); })
.catch(function(reason) { console.log(JSON.stringify(reason.error));});
i get result as :
{"duration":"19ms",
"next":"",
"results":[{
"actor":"user:1",
"foreign_id":"flat:4",
"id":"41231d40-ca5a-11e5-8080-800047dac62a",
"message":"#flat_4_bfcaffca-c35f-11e5-8080-8001002e75f6",
"object":"tweet:4",
"origin":null,
"target":null,
"time":"2016-02-03T09:41:09.335584",
"to":[],
"verb":"tweet"
}]
}
in your rest_ documentation
https://getstream.io/docs_rest/#feed_detail
you have specified
feed/(feed_slug)/(user_id)/(activity_id|foreign_id)/
to delete an activity for if the foreign key matches criteria.
in your nodejs code
user1.removeActivity({foreignId: 'flat:4'})
line works to remove the feed for that user where foreign key is flat:4
user1.get({foreignId: 'flat:4'})
does not work
can you please help if i want to get feeds with the foreignId as 'flat:4'
is there any way for such ?
please help as i'm stuck on this point only.
The feed/(feed_slug)/(user_id)/(activity_id|foreign_id)/ endpoint is only for DELETE requests. At this present is not possible to retrieve activities by its foreign_id. That field can only be used to perform cascaded deletion and/or to define the uniqueness of your data.
Looking at the code that you added, it seems like to use references to feeds as the value for foreign_ids, if that's the case then you are probably using this field in a weird/wrong way and you should create a new question on SO to ask help with the integration of your data.

Google Groups API wrong output

In Google Script Project I have 2 Google-API functions that should give out the same output.
can somebody please explain to me what I am wrong with, or maybe is it a bug in the API?
I have a group with 904 members.
Function "listMembersOfGroup1" is using the "GroupsManager" API, and is working correctly. the Logger displais "904.0".
And here is the code:
function listMembersOfGroup1() {
var group = GroupsManager.getGroup("group#domain.com");
var members = group.getAllMembers();
Logger.log(members.length);
}
But function "listMembersOfGroup2", which is using the "GroupsApp" API, is not working correctly (as far I understand). the Logger displais "753.0".
And here is the code:
function listMembersOfGroup2() {
var group = GroupsApp.getGroupByEmail("group#domain.com");
var users = group.getUsers();
Logger.log(users.length);
}
Is there any good reason why the "GroupApp" API gives out a different number?
Thanks in advance for your help.
.
(This is my first question on my first day on this site, I hope my question follows the rules.)
Welcome to StackOverflow. Your post was well explained.
The first API GroupsManager is used by domain administrators to manage their domain groups Check Here.
The secong one GroupsApp is used to manage google groups Google Groups API.
Your second call is retrieving users that belongs to the google groups mail passed as URL. Check full documentation here
So you're working with different google products.

Categories

Resources