LinkedIN has recently released support for webhooks and we are successful in creating a webhook url. We are able to authorise a user administrator of a company to our app and get permissions to write and read from the REST API.
However we are not receiving any webhook updates from the app for that company. And there is no documentation on how to subscribe to a particular company like in other social-media API:s witch we have vast experience from (fb,IG,Twitter).
The documentation on LinkedIn is very limited on the subject. And we are not sure what we can expect from the webhook requests from linkedIn. What is the reason we are not getting Webhooks for that company?
We dont even get webhook calls for the organisation owning the app.
Any help appreciated.
https://learn.microsoft.com/en-us/linkedin/shared/api-guide/webhook-validation?context=linkedin/context
I figure it out I need to add header json to output for validation.
Here is my code in php
if (isset($_REQUEST['challengeCode'])) {
header('Content-Type: application/json');
echo json_encode([
'challengeCode' => $_REQUEST['challengeCode'],
'challengeResponse' => hash_hmac('sha256', $_REQUEST['challengeCode'], 'client secret'),
]);
exit;
}
and for webhook subscription
$api->setApiHeaders([
'X-Restli-Protocol-Version' => '2.0.0',
]);
$developerUrn = urlencode("urn:li:developerApplication:developerid");
$personUrn = urlencode("urn:li:person:personid");
$orgUrn = urlencode(""urn:li:organization:pageid");
$endpoint = "(developerApplication:$developerUrn,user:$personUrn,entity:$orgUrn,eventType:ORGANIZATION_SOCIAL_ACTION_NOTIFICATIONS)";
$api->api("eventSubscriptions/$endpoint", ['webhook' => "WEBHOOK_URL"], 'PUT');
Webhooks are a closed beta feature at this time:
Who can use this: Any developer using a webhooks API (currently available only for social action notifications on company posts to beta partners)
Source: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/recent-changes
Related
In my Xamarin Forms 5 app, I'm using the in-app purchase plugin. I'm now trying to verify this purchase in my ASP.NET backend API by calling the AppStore API.
When a purchase goes through, the response object I receive looks like below:
The AppStore API documentation indicates that the request body for the POST call I need to make should include the following properties:
I'm trying to figure out what I need to send as receipt-data which is supposed to be of type byte.
So far, I tried sending the PurchaseToken property I receive in the response object -- using the In-App Plugin -- see first image above. That failed. I then converted the PurchaseToken value to a byte array using the following conversion and that failed too.
var byteValue = Encoding.ASCII.GetBytes(purchaseTokenValue);
I keep getting { "status": 21002 } from AppStore API which apparently means malformed according to this post.
Has anyone called AppStore API for purchase verification using the data from the In-App Billing plugin? I'd appreciate some pointers here. Thanks!
UPDATE:
I also installed the beta version of the plugin (6.3.2 Beta). Even though the response object has changed, I still don't see any data about the receipt e.g. receipt-data.
The final solution is as follows. First, I upgraded to the latest (pre-release) Beta version of the plugin. In my case that ended up being 6.3.2-beta.
In the case of iOS, the receipt data does NOT come in the transaction object we get for the purchase. I'm providing the code including the purchase call and platform specific steps so that it's clear for everyone:
// First, make the purchase call and get transaction data
var purchase = await billing.PurchaseAsync(productId, ItemType.Subscription);
// We then handle platform specific steps
if (Device.RuntimePlatform == Device.Android)
{
// Must call AcknowledgePurchaseAsync else the purchase will be refunded
await billing.AcknowledgePurchaseAsync(purchase.PurchaseToken);
}
else if(Device.RuntimePlatform == Device.iOS)
{
// Grab receipt data
var receiptData = CrossInAppBilling.Current.ReceiptData;
}
I have 10000 users, and i want to push notification SNS to each user, with different message.
So, i cannot use Topic in this case.
The problem is it delay too much. (About 1h30 hour for this to complete)
Any solution?
Thank you so much!
Endpoint is something like internal AWS Identificator for combination: platform+device token or smth else. When we want to send an message we use it as address point instead of real.
About adding Endpoint to SNS. Generally it looks like so:
You should register your platform in AWS SNS and receive e.g. for IOS - iOS app's Application ARN. It can be done via e.g. AWS Web Console
After you should create for each target user its endpoint with method like this:
$endPoint = $snsClient->createPlatformEndpoint([
'PlatformApplicationArn' => $SNS_APP_ARN,
'Token' => 'phone token'
]);
phone token for push notification is device-token. Endpoint generally is array/object which contains EndpointArn. Use it address when send message.
After that you can send an message to specific endpoint.
$snsClient->publish(
array(
'Message' => $pushMessage,
'TargetArn' => $endpointArn
));
earlier in 2015 i started creating a website with drupal 7 that imports instagram-content (images, likes, comments etc.) via Drupal Feeds. Everything worked finde, but the projects stopped then.
Now it seems we start that again but suddenly the import is not working anymore. I always get the following error:
{"meta": {"error_type": "OAuthPermissionsException", "code": 400,
"error_message": "This request requires scope=public_content, but this
access token is not authorized with this scope. The user must
re-authorize your application with scope=public_content to be granted
this permissions."}}
I didnt had to send the "public_content" earlier, so i was just sending "basic"-scope access. And as i said, everything worked well.
Now i inserted also the scope for "public_content" along with "basic" within the oauth-Module for feeds. But still getting the error-message above.
Any hints on that?
Thanks in advance and regards,
Fab
This is due to a Instagram Platfrom Update
You'll have to add public_content scope as Joshi has pointed out - and also you'll need to renew your auth token in the settings page.
Then you'll be good to go.
Here is the solution:
Use following code in instagram_social_feed.module
Function: instagram_social_feed_settings()
if (variable_get('instagram_social_feed_client_id', '') != '' && variable_get('instagram_social_feed_redirect_uri', '') != '') {
$form['authenticate'] = array(
'#markup' => l(t('Click here to authenticate via Instagram and create an access token'),
'https://api.instagram.com/oauth/authorize/?client_id=' . variable_get('instagram_social_feed_client_id') . '&redirect_uri=' . variable_get('instagram_social_feed_redirect_uri') . '&response_type=code&scope=public_content'
)
);
}
This will solve the issus
According to this https://developers.google.com/youtube/v3/guides/push_notifications
I can subscribe to a youtube channel & receive push notification for any new video.
My callback server is a php script which interprets POST/GET data:
<?php
if (isset($_GET['hub_challenge'])) {
print $_GET['hub_challenge'];
}
else {
$xml=file_get_contents("php://input");
file_put_contents('endpoint.txt',$xml);
}
?>
But $xml is empty. In the docs it says:
The YouTube Data API (v3) supports push notifications via
PubSubHubbub, a server-to-server publish/subscribe protocol for
Web-accessible resources. Notifications are pushed out to subscribers
via HTTP webhooks, which is much more efficient than polling-based
solutions.
But it does not specify how does it send the data....whether in POST body or in somewhere else.
So How do I get the atom feed in my script?
EDIT: I should probably ask a new question for this...but anyway....I tried this channel (https://www.youtube.com/channel/UCATp8LNTjzjNlLxdArp0Myg); but when I try to subscribe it says "restricted topic" (I did not provide token as it is a public channel). Same for any other channel ID. Is something wrong with my callback server? I also tried runscope url as a callback server for testing. But it did not help.
Others are having similar problems. Here is the issue log:
https://code.google.com/p/gdata-issues/issues/detail?id=7138
and related StackOverflow question:
Youtube API - Subscribing to Push Notifications
Unfortunately, no one seem to provide a solution although you can follow the issue and track any progress.
Yes it send data on the POST body . If you are using Express Nodejs add app.use(bodyParser.xml()) middleware to parse xml data
I've desperately tried to figure this out on my own, and did not want to come to SO with this question, but I'm at my wits end (no thanks to the api / oauth docs).
I'm working in PHP and I'm trying to avoid using the Google_Client and AnalyticsService classes, by using REST on the analytics.data.ga.get method.
STEP #1: Create an API Project for a Web Application
I go to the api console and create a project with analytics services and get an OAuth Client ID and Secret.
I'm under the impression that I can create a Client ID for an Installed Application or a Web Application because I'm doing the initial token handshaking manually. Please correct me if I'm wrong.
I create a Client ID for web applications and get my Client ID xxxxxxxxxxxxxx.apps.googleusercontent.com, Client secret yyyyyyyyyyyyyyy, and my Redirect URI is http://localhost:9002
STEP #2: Request initial API access
I enter this link; https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=xxxxxxxxxxxxxx.apps.googleusercontent.com&redirect_uri=http://localhost:9002&scope=https://www.googleapis.com/auth/analytics.readonly&access_type=offline
The access_type=offline is because I'm using REST, and do not expect "the user" (myself) to manually deal with redirects / popups every time I need a refreshed token.
The above request returns http://localhost:9002?code=4/KModH0K_xxxxxxxxxxxxxxxxxxx9Iw.gikOaYRDWywTshQV0ieZDArCOX8XdwI
Code 4/KModH0K_xxxxxxxxxxxxxxxxxxx9Iw.gikOaYRDWywTshQV0ieZDArCOX8XdwI is my permission to request the API Token.
STEP #3: Request First Token
Because of my company’s IT issues, I’m forced to use PHP 5.2.17 and I do not have access to PHP cURL, so I’m using file_get_contents and stream_context_create.
The first token is requested with a PHP file_get_contents();
$opts = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => 'code=4/KModH0K_xxxxxxxxxxxxxxxxxxx9Iw.gikOaYRDWywTshQV0ieZDArCOX8XdwI&client_id=xxxxxxxxxxxxxx.apps.googleusercontent.com&client_secret=yyyyyyyyyyyyyyy&redirect_uri=http://localhost:9002&grant_type=authorization_code'
)
);
$context = stream_context_create($opts);
$result = file_get_contents('https://accounts.google.com/o/oauth2/token', false, $context);
var_dump($result);
The content parameters must be in a single line.
The above code returns my access_token and refresh_token in json format
string(195) "{ "access_token" : "ya29.AHES6wwwwwwwwwwwwwwwVEBXE6XRbC-Q-pP0wZWdoIm9H804ro", "token_type" : "Bearer", "expires_in" : 3600, "refresh_token" : "1/8tXvdUKcSEcaaxVqqqqqqqqqqqqqoYpj2KSS9qwWI" }"
The refresh token I must store in a safe place, like a DB or protected txt file, which is called upon when my access_token has timed out.
STEP #4: Request Analytics Data
Now from what I understand, I’m ready to roll and should be able to use my access_token to make requests to https://www.googleapis.com/analytics/v3/data/ga.
I do this by sending this request;
$request = 'https://www.googleapis.com/analytics/v3/data/ga' .
'?ids=ga%3Aaaaaaaaa' .
'&start-date=2012-12-07' .
'&end-date=2012-12-09' .
'&metrics=ga%3Avisits';
$opts = array(
'http' => array(
'method' => 'GET',
'header' => 'Content-Type: application/x-www-form-urlencoded\r\n' .
'Authorization: Bearer ya29.AHES6wwwwwwwwwwwwwwwVEBXE6XRbC-Q-pP0wZWdoIm9H804ro \r\n'
)
);
$context = stream_context_create($opts);
$result = file_get_contents($request, FALSE, $context);
var_dump($result);
This request returns a 401 Unauthorized error. I take this as meaning my request is properly formed and making the connection to https://www.googleapis.com/analytics/v3/data/ga.
Also, according to this doc Getting Full Quota, I can make the request with the access_token in the URL like this;
$request = 'https://www.googleapis.com/analytics/v3/data/ga' .
'?ids=ga%3A48564799' .
'&access_token=ya29.AHES6wwwwwwwwwwwwwwwVEBXE6XRbC-Q-pP0wZWdoIm9H804ro' .
'&start-date=2012-12-07' .
'&end-date=2012-12-09' .
'&metrics=ga%3Avisits';
$result = file_get_contents($request, FALSE);
$result = json_decode($result);
var_dump($result);
This time I receive 403 error, in which google includes the response User does not have sufficient permissions for this profile.
QUESTION #1
Am I’m missing something in the API console or a process in the token acquisition? I’m assuming I’m not, because I’m ultimately acquiring the access_token=ya29 and refresh token.
QUESTION #2
Maybe I’m completely off basis in assuming I can do this with simple https reqests? Do I have to use the Google_Client and AnalyticsService classes? I don’t think this is the case, but maybe I’m wrong.
QUESTION #3
Do I need to use a ‘key’ in my request?
&key=bbbbbbbbbbbbbbbb
QUESTION #4
By using PHP 5.2.17 am I missing something? (besides 5.3 or 5.4 themselves)
For example, in some versions of PHP, in stream_context_create, the header should be in an array and not a string, like this;
$opts = array(
'http' => array(
'method' => 'GET',
'header' => array(
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Bearer ya29.AHES6wwwwwwwwwwwwwwwVEBXE6XRbC-Q-pP0wZWdoIm9H804ro '
)
)
);
But I don’t think that it’s an issue in my case. I’m just curious if these HTTP request need to be formed a different way (without using curl).
Any insights and thoughts would be greatly appreciated
Here’s my dim witted mistake that nearly gave me a heart attack.
I typically do my development work in Chrome. And my Chrome browser was signed into my gmail account personal#gmail.com. However, my analytics account, which is under my work#gmail.com was open in FireFox (try not to laugh to hard).
I’m not 100% sure this is correct, but I think this is the general flow. When I did STEP #2: Request initial API access, I did this in my Chrome browser. The endpoint https://accounts.google.com/o/oauth2/auth was authorizing my personal#gmail.com account. And my STEP #4 API request https://www.googleapis.com/analytics/v3/data/ga was looking for an analytics profile under my personal#gmail.com account. Which of course doesn’t exist.
I literally wasted 15 hours on this. This is dumber than trying to troubleshoot an update… and forgetting to flush the cache.
Sorry for wasting your time.
EDIT REFRESH TOKENS
I've once again run into issues with this API and found out the hard way that GA will revoke Refresh Tokens if too many different clients use the token, at least I think that was the problem.
Further reading can be found here.
I got a 403 today and found the cause: in the get function I was using the account ID instead of the profile ID. Switching to the profile ID fixed it for me.
It could be a problem with CURL request. In the GoogleAnalyticsAPI.class.php > class Http > function curl (around line 720) add one more option to stop CURL from verifying the peer's certificate:
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);