Get the num followers with linkedin API v2 - rest

The num followers of linkedin API is not working anymore. We used to use https://api.linkedin.com/v1/companies/11543/num-followers, but it responds with the error listed below.
{
"errorCode": 0,
"message": "This resource is no longer available under v1 APIs",
"requestId": "EUBVUH7QTU",
"status": 410,
"timestamp": 1561391381048
}
We need to get this number with v2 but it seems to have been deprecated in v2 according to these docs.
The totalFollowerCounts field is deprecated and will stop being
included in responses after January 31, 2019.
Is there a way to get the number of followers using V2 of LinkedIn's API?

David.
I think you already know that V1 Api version has been deprecated, and you have to migrate all your code to the new V2 endpoints.
Assuming your APP already has access to the V2 version, you can get the follower statistics using this V2 endpoint.
If you need to get the followers statistics by segments, you can use this other endpoint, where you can pass many arguments (region, language, seniority...)

You can access the followers using the following url
https://www.linkedin.com/pages-extensions/FollowCompany?id={companyId}&counter=bottom
Replace companyId with your companyId.
This will result in a webpage that can be easily parsed.
result
Example in code:
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://www.linkedin.com/pages-extensions/FollowCompany?id={companyId}&counter=bottom");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
var payload = await response.Content.ReadAsStringAsync();
var doc = new HtmlDocument();
doc.LoadHtml(payload);
var node = doc.DocumentNode.SelectNodes("//div[contains(#class, 'follower-count')]");
var f = node.FirstOrDefault().InnerText;
source: https://taras.codes/blog/linkedin-organization-follower-count/

It seems that your app doesn't have full access to the V2 version of the Linkedin API, because I assume your token can manage the company with ID 11543, right?
In this case, you have to apply to the Marketing Developer Platform, accesible from the Linkedin Apps Console, because the access to V2 version is restricted, and not all apps that apply get this permission.

Related

How to use Azure AD Graph API to create a new AppRoleAssignment

I'm trying to figure out how to create a new appRoleAssignment using the Azure AD Graph API. (It appears that the newer Microsoft Graph does NOT support creating app role assignments just yet). I want to use the default role.
var assignment = new Dictionary<string, string>();
assignment["id"] = "00000000-0000-0000-0000-000000000000";
assignment["principalId"] = "user-guid";
assignment["resourceId"] = "service-principal-guid";
var url = "https://graph.windows.net/{tenant.onmicrosoft.com}/servicePrinciapls/{service-principal-guid}/appRoleAssignments";
I also tried posting to:
var url = "https://graph.windows.net/{tenant.onmicrosoft.com}/appRoleAssignments";
I'm POSTing the data in the hopes to create the assignment but it is giving a 404 error.
The assignment dictionary gets converted to JSON and posted.
In this answer we discussed the endpoint to GET app role assignments for a user. The same endpoint is the one you would POST to to create a new app role assignment:
POST https://graph.windows.net/{tenant-id}/users/{id}/appRoleAssignments?api-version=1.6
...
{
"principalId":"{user-object-id}",
"resourceId":"{service-principal-object-id}",
"id":"00000000-0000-0000-0000-000000000000"
}
(In the example above, we use 00000000-0000-0000-0000-000000000000 as the app role ID because we want to create a default assignment (i.e. "no role"). This would correspond to the id of an AppRole in the ServicePrincipal object if we wanted to assign the user to a specific app role.)
Instead of using the servicePrincipal collection, we need to use the user entity to create the appRoleAssignment for the users. Here is an example for your reference:
POST:https://graph.windows.net/{tenant}/users/{userObjectId}/appRoleAssignments?api-version=1.6
authorization: Bearer {access_token}
Content-Type: application/json
{
"id":"00000000-0000-0000-0000-000000000000",
"resourceId":"{servicePrincipId}",
"principalId":"{userObjectId}"
}

Add a subpanel record to a SugarCRM account through REST API

Question: How do I create a subpanel record through the SugarCRM rest api endpoint for accounts?
Steps taken so far:
I've added a new package called, "transactionHistory" with a module named, "InvoiceHistory" using the SugarCRM studio.
I added a One to Many relationship to the Accounts module using studio.
I'm using NetSuite to push new invoices to the new module's record via the subpanel "create" option. Here's the code I'm using:
function createSugarTransaction(transaction, token) {
var url = 'https://crm.techsoft3d.com/rest/v10/Accounts/' + transaction.customer;
var headers = {
"Content-Type": "application/json",
"OAuth-Token": token
};
var now = (new Date()).toISOString();
var body = {transactionHistory_InvoiceHistory:
{
create: [{
name: transaction.docId,
transaction_date_c: transaction.date,
invoice_status_c: transaction.status,
due_date_c: transaction.duedate,
total_amount_c: transaction.total,
amount_due_c: transaction.remaining,
start_date_c: transaction.startdate,
end_date_c: transaction.enddate
}]
}
};
var response = nlapiRequestURL(url, JSON.stringify(body), headers, 'PUT');
return response;
}
The transaction object has been validated and the json object within the create: [] array has matching sugar fields (key) with the corresponding transaction object values.
When making the API call to sugar I'm successfully authenticated and have access to the custom module and accounts - so no problem there. However, when the call is returned to response it's showing the following error:
{"error":"no_method","error_message":"Could not find a route with 1 elements"}
I'm unsure of what else is needed in order for the record to be created. According to sugar's help documentation and developer community this should work. I'm using the basic information provided by sugarcrm support portal:
http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.6/API/Web_Services/Examples/v10/module_POST/
According to other blog posts within the developer community, it should be as simple as adding the subpanel name, followed by an array of fields under the "create" object... similar to this:
var requestBody = { package_module:create[{name:value}]};
My initial thinking of what's wrong is:
1. my package_module name isn't correct, but I'm unable to find it anywhere within the applicaiton or help documentation.
2. the request body isn't formatted properly, even though it's structure was copied from this article https://developer.sugarcrm.com/2014/02/28/sugarcrm-cookbook2/
Any help would be appreciated.
try the createRelatedRecord api endpoint
type {sugarurl}/rest/v10/help to see a list of endpoints to look through, most of which have documentation and examples
https://crm.techsoft3d.com/rest/v10/help
your API url should have the name of the link (relationship) you want, in addition to the values in the POST payload
https://crm.techsoft3d.com/rest/v10/Accounts/{transaction.customer}/link/accounts_transactionhistory (or whatever your link's name is)
per the documentation for this endpoint, you just specify the field values in the payload
{
"first_name":"Bill",
"last_name":"Edwards"
}

Deezer API endpoint with details about parnter/co-branded subscription

I'm looking for Deezer API endpoint returning info about subscription via partner and/or co-branding detail.
For example, similar data as available on https://www.deezer.com when signed in with an account subscribed with a partner/co-branding options (available in included javascript):
var CUSTO = {
"id":0,
"logos": {
"header":"logo_telekomslovenije_trans-v00341265",
"logo_link":"",
"logo_position":"bottom"
},
"tab_header":{
"name":"",
"color":"",
"url":"",
"iframe_url":"",
"iframe_height":760,
"iframe_width":"990px"
},
"store_platform":"deezer"
};
var COBRANDING = 'none';
Additionally it might be handy if available subscription INFOS / offers http://api.deezer.com/infos would also contain partner/co-branded subscription options for given country of unsubscribed (free) user.
Thank you.
Unfortunately, these endpoints do not exist and will not be implemented, sorry.

Facebook Registration | Custom Fields Not Returning

I'm attempting to create a Facebook Registration process for our website that will create an account for the user in our CRM - to this end I require the use of a few custom fields in the registration form.
I have the registration form appearing properly on the site, however, when I process the signed_request the JSON only returns the decoded standard items and not my custom fields:
{
"algorithm": "HMAC-SHA256",
"code": "2.AQDp0sgWRw3TWrII.3600.1330650000.1100001862544007|LwjvMjADtPxaIzxizYuIivNdi7w",
"issued_at": 1330644064,
"user_id": "<my user id>"
}
This is a .NET implementation but I am not using the Facebook C# SDK as none of the documentation seems to be available anymore on their site and I'm just not clever enough to figure it out. I tried using the new 6.x beta of the Facebook C# SDK and the Facebook.Client() parse method but didn't have any luck determining what to do with it once the thing was parsed.
So - this stolen code is what I used to get the results posted above:
//client_payload = the signed_request from Facebook
string[] sB64String = client_payload.Split('.');
string payload = client_payload.Replace((sB64String[0] + "."), string.Empty);
var encoding = new UTF8Encoding();
var decodedJson = payload.Replace("=", string.Empty).Replace('-', '+').Replace('_', '/');
var base64JsonArray = Convert.FromBase64String(decodedJson.PadRight(decodedJson.Length + (4 - decodedJson.Length % 4) % 4, '='));
var json = encoding.GetString(base64JsonArray);
var jObject = JObject.Parse(json);
response.write(Convert.ToString(jObject)); // rw for debugging
Maybe I'm missing something?
I've resolved this on my own by modifying the way I was going about it.
I ended up using the tag and client side cookie as found here:
https://developers.facebook.com/docs/plugins/registration/advanced/
All of my custom fields end up in the cookie that I can then parse and send to my .NET webservice. Kind of a round-about way of doing it but it's getting the job done now.

How can I construct a link to view a message on facebook.com if I have the message id

I am retrieving the messaging inbox with the following graph api call:
https://graph.facebook.com/me/inbox?access_token=...
It returns an array of messages that each have an identifying "id" (same as message id as returned by FQL)
I would like to be able to provide a link for the user to view a message directly on Facebook.com.
Something like: https://www.facebook.com/messages/?action=read&tid=....
That is the link you get to if you you browse to a message from facebook itself.
However I can't seem to find a way to discover the correct tid from either the Graph API or FQL.
I haven't had any luck in figuring out an alternative URL either.
This url used to work, but is broken for me now: http://facebook.com/?sk=messages&tid=...
It just redirects to the top level messaging page: https://www.facebook.com/messages/
ANY IDEAS?
Thanks so much
From graph API get to me/inbox the result set gives id as part of each object returned. This is also thread_id.
If the id you have is a string object (probably a guid), this is from Facebook's older message system storage structure. Now they've updated to a new storage structure that requires the old ones to be migrated into the new
So you have a fairly easy check:
If thread id is a long (Int64/BigInt), then you have a new thread and can use
http://www.facebook.com/messages/?action=read&tid=id.THREAD_ID
If thread id is a string then you have a older thread and can use
http://www.facebook.com/messages/?action=read&tid=THREAD_ID
many programming languages have their own form of checking the type of a value.
var threadId = (string)data.thread_id;
var longVal = 0L;
var isLong = Int64.TryParse(threadId, out longVal);
var threadUrl = (isLong) ?
"http://www.facebook.com/messages/?action=read&tid=id." + threadId :
"http://www.facebook.com/messages/?action=read&tid=" + threadId;