Is there anyway to update company status of linked in company pages via API call using PHP,
There is no way to create what LinkedIn refers to as a 'share' for a company at this point. Here is a post on their forums relating to this.
This is a very quick guide. Take a look at my decision using the LinkedIn API. Have in mind that before doing that:
you must have a personal profile in LinkedIn;
your company must have a company page in LinkedIn (http://www.linkedin.com/company/yourcompanyname);
you must be an administrator of your company page (in order to publish updates on behalf of your company).
When the above conditions are met go to https://www.linkedin.com/secure/developer and sign in with your personal profile credentials. Add a new application in order to get API Key, Secret Key, OAuth User Token and OAuth User Secret.
PHP code for LinkedIn API on your side to post company shares:
require 'OAuth.php'; // .. or install the PECL extension.. Google it
$apiKey = 'xxxxxxx'; // take it from your application
$apiSecret = 'yyyyyyyyy'; // take it from your application
$accessToken = 'zzzzzzzzz'; // take it from your application
$accessToken = 'kkkkkkkkkkk'; // take it from your application
$oauth = new OAuth($apiKey, $apiSecret);
$oauth->setToken($accessToken, $accessTokenSecret);
$body = new stdClass();
$body->comment = 'Some comment';
$body->content = new stdClass();
$body->content->title = 'Some title';
$body->content->description = 'Some description';
$body->content->{'submitted-url'} = 'http://www.mycompany.com/article_id/123456'; // ID of your company page in LinkedIn
$body->visibility = new stdClass();
$body->visibility->code = 'anyone';
$body_json = json_encode($body);
$oauth->fetch('http://api.linkedin.com/v1/companies/12345678/shares', $body_json, OAUTH_HTTP_METHOD_POST, array(
"Content-Type" => "application/json",
"x-li-format" => "json"
));
$response = json_decode($oauth->getLastResponse());
I hope it helps.
The accepted answer for this question is no longer valid and another answer linking to the announcement that it is now available has two broken links
To clarify, you can now post company status updates/shares and the documentation for this is located at https://developer.linkedin.com/docs/company-pages#company_share
As of August 2013, LinkedIn's API supports sharing to company pages.
Announcement.
Official documentation.
Related
I can't get the Locations list from my business under my code (PHP using the "Google APIs Client Library for PHP" together with "Google_Service_MyBusiness" Classes) when I use the "Service Account" authentication, the API returns an empty Location List.
I already have the Prerequisites and did the Basic setup, by the way, I got the information with success on OAuth Playground, under a specific AccountId, Eg: 1111111111, provided by another response there on the "OAuth Playground".
(PS: I tested with my "PERSONAL" and "LOCATION_GROUP" accounts and got success with both).
But when I try to do it over my code via Server Account authentication, I can't get all the information, just the Account data that return another AccoundId, Eg: 2222222222, different of the Accounts that I got on OAuth Playground.
I did the Authentication process on OAuth Playground, using the same project where I created the "Service Account", by the way, the Permission of this "Service Account" is OWNER.
Previously, my role in my company on the Google My Business was "SITE_MANAGER", so I saw a forum answer where just "MANAGER" level/role can list the Locations, so I requested to change my permission, but continues as not the success on Locations listing.
So, I saw another Google My Business support article recommending create a "Location Group" and put my current "Location" into this group to make easy handle it, I did it and no success again.
My code is simple, based on Google guide, OAuth 2.0 for Server to Server Applications, and some Forum Questions (BTW the author's question have the same issue than me):
<?php
putenv('GOOGLE_APPLICATION_CREDENTIALS=service-account-credentials.json');
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope("https://www.googleapis.com/auth/plus.business.manage");
require_once('Google_Service_MyBusiness.php');
$mybusinessService = new Google_Service_MyBusiness($client);
$accounts = $mybusinessService->accounts;
$accountsList = $accounts->listAccounts()->getAccounts();
foreach ($accountsList as $accKey => $account) {
var_dump('$account->name', $account->name);
$locations = $mybusinessService->accounts_locations;
$locationsList = $locations->listAccountsLocations($account->name)->getLocations();
var_dump('$locationsList', $locationsList);
// Final Goal of my Code
if (empty($locationsList)===false) {
foreach ($locationsList as $locKey => $location) {
$reviews = $mybusinessService->accounts_locations_reviews;
$listReviewsResponse = $reviews->listAccountsLocationsReviews($location->name);
$reviewsList = $listReviewsResponse->getReviews();
var_dump('$reviewsList', $reviewsList);
}
}
}
I expected the Location of my business (also the reviews, but it a next step), but I just got the empty Location list.
Finally, I got success using the ClientId/ClientSecret keys together with Refresh Token previously received on Google OAuth 2 Playground on the first time that I give permission to (my) App, instead "Service Account" authentication way :)
$client = new Google_Client();
$client->setClientId($clientId);
$client->setClientSecret($clientSecret);
$client->addScope("https://www.googleapis.com/auth/plus.business.manage");
$client->setSubject('my email user on GMB');
$client->refreshToken(' ###### ')
Now I got all the needed data for my application.
I'm trying to add a yahoo login to a php website using Yahoo! Social SDK - PHP5 which seems the official and most updated PHP SDK
I created an app from https://developer.yahoo.com/apps/create/ and followed the instructions provided in examples.
So at this early point I have to define Client ID, Client Secret, Application ID and the Callback URL to set the YahooOAuthApplication class.
$CONSUMER_KEY = '##';
$CONSUMER_SECRET = '##';
$APPLICATION_ID = '##';
$CALLBACK_URL = '##';
$oauthapp = new YahooOAuthApplication($CONSUMER_KEY, $CONSUMER_SECRET, $APPLICATION_ID, $CALLBACK_URL);
I visited https://developer.yahoo.com/apps/ and chose the application I previously created but I couldn't find the Application ID.
I also tried the last part of the url when in application but that didn't work either.
Go to https://developer.yahoo.com/apps/
Clic on your app
See URL, you'll get something like this :
https://developer.yahoo.com/apps/TKI2Mw7f/
The key TKI2Mw7f at the end is your appID (This is an example)
I am afraid whether Yahoo provides Application ID for latest APIs versions, please check their documentation.
For testing purposes, I'd like to get my own full profile datas from LinkedIn API.
So far my code looks like this :
// Fill the keys and secrets you retrieved after registering your app
$oauth = new OAuth("APIKEY", "SECRETKEY");
$oauth->setToken("Token OAuth", "Secret User OAuth");
$oauth->disableSSLChecks();
$params = array();
$headers = array();
$method = OAUTH_HTTP_METHOD_GET;
// Specify LinkedIn API endpoint to retrieve your own profile
$url = "https://api.linkedin.com/v1/people/~:(first-name,last-name,headline,location:(name),skills:(name),educations:(id,school-name,field-of-study))?format=json";
// By default, the LinkedIn API responses are in XML format. If you prefer JSON, simply specify the format in your call
// $url = "https://api.linkedin.com/v1/people/~?format=json";
// Make call to LinkedIn to retrieve your own profile
$oauth->fetch($url, $params, $method, $headers);
$oProfile = json_decode($oauth->getLastResponse());
var_dump($oProfile);
Although I am getting basic profile informations (firstName,headline etc...) but when it comes to full profile informations I get an object with '...' as value everytime, although the informations exist.
I have r_fullprofile ticked in my LinkedIn app interface, so I don't know what I have to do to get these values.
I tried your query with my own account. It looks you issue is with the skills field.
You can see in the LinkedIn API documentation that skills are made up of a skill, and each skill has a name. If you only want the name returned the proper way to ask for it is
skills:(skill:(name)), whereas your request asks for skills:(name).
Here is an updated request for you:
GET https://api.linkedin.com/v1/people/~:(first-name,last-name,headline,location:(name),skills:(skill:(name)),educations:(id,school-name,field-of-study))?format=json
Im getting started with the php sdk, and struggling to understand a few things (I have a basic example below - but everytime the pic goes to MY wall and not the fan page)
Code:
require_once("facebook.php"); // set the right path
$config = array();
$config['appId'] = 'app id';
$config['secret'] = 'app secret';
$config['fileUpload'] = true; // optional
$fb = new Facebook($config);
$params = array(
// this is the access token for Fan Page
"access_token" => "I create this via the graph api (select App and click get token), I select publish stream and photo_upload permissions.",
"message" => "test message",
"source" => "#" ."photo.png", // "#" .
);
try {
// **** is Facebook id of Fan page
$ret = $fb->api('/****/photos', 'POST', $params);
echo 'Photo successfully uploaded to Facebook Album';
} catch(Exception $e) {
echo $e->getMessage();
}
the picture keeps going to MY wall (logged in user) and not the fan page, is that because im getting a token for the currently logged in user (me) instead of the fan page? and if so how do i generate a token for the fan page whilst logged in as the developer? (is it by putting the fan page id into the Get bar?)
Apologies for the noob questions but the facebook documentation sucks (until u understand the core functionality of course). Most tutorials work once u know how to use the graph API - none ive looked actually EXPLAIN how to use the graph to generate correct tokens, etc.
\POST /<ID>/photos — this will post on the <ID>'s wall only, so please double-check the <ID> that you are using.
The access token will depict that on behalf of whom the photo would be posted on the <ID>'s wall. If you use the user access token, the photo will be published on behalf of the user and if page access token is used, it will be published on the page's behalf itself.
You can get the page access token of your pages by-
\GET /me/accounts?fields=access_token
(permission required: manage_pages)
Demo
I am working on a script to pull recent Facebook posts/status updates for a specific using the Facebook API. I downloaded the FB SDK and searched all over the FB developers site, SO, and other places and it seems like the code below should accomplish what I need. However, although I am not getting an error, I am getting a NULL result.
require 'facebook-php-sdk/src/facebook.php';
$facebook = new Facebook(array(
'appId' => 'XXXXXXXXXXXX',
'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXX',
));
$fbApiGetPosts = $facebook->api('***My Name***/feed?limit=5');
var_dump($fbApiGetPosts["data"]);
I have tried using my two FB accounts,(my personal acct and a test account that I created just for this project) as well as one for my company and each time the response was NULL. When I misspelled the account name or used a name that did not exist I got an error, which seems to suggest the request is going somewhere.
In the code above, I also tried var_dump-ing $fbApiGetPosts and that result was also null
Can anybody see what the missing piece of the puzzle is?
I've not used the Facebook SDK, but here is how I retrieve Facebook posts:
$appId = 'XXXXXXXXXXXX';
$token = 'XXXXXXXXXXXXXXXXXXXXXXXX';
$posts = json_decode(
file_get_contents('https://graph.facebook.com/' . $appId . '/feed?
access_token=' . $token
)
);
var_dump($posts->data);
Hopefully this helps!
EDIT:
The token is just called an "Access Token". Here are the instructions for obtaining one. You might find the Access Token Tool helpful, but it's more for debugging existing tokens then creating new ones.
Just use the PHP SDK :
download link : https://developers.facebook.com/docs/php/gettingstarted/
Log your app :
$facebook = new Facebook(array('appId' => 'XXXXX','secret' => 'XXXXX'));
$facebook->setAccessToken('stored access token');
then :
$fbApiGetPosts = $facebook->api('/me/feed');
print_r($fbApiGetPosts);
Here is the Graph doc : https://developers.facebook.com/docs/graph-api/reference/
and the /feed ref : https://developers.facebook.com/docs/graph-api/reference/user/feed/