Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix response for empty body #1

Merged
merged 9 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

46 changes: 0 additions & 46 deletions CODE_OF_CONDUCT.md

This file was deleted.

4 changes: 0 additions & 4 deletions CONTRIBUTING.md

This file was deleted.

6 changes: 0 additions & 6 deletions ISSUE_TEMPLATE.md

This file was deleted.

21 changes: 0 additions & 21 deletions LICENSE.md

This file was deleted.

54 changes: 16 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
LinkedIn API Client with OAuth 2 authorization written on PHP
============================================================
[![Build Status](https://travis-ci.org/samoritano/linkedin-api-php-client.svg?branch=master)](https://travis-ci.org/samoritano/linkedin-api-php-client) [![Code Climate](https://codeclimate.com/github/samoritano/linkedin-api-php-client/badges/gpa.svg)](https://codeclimate.com/github/samoritano/linkedin-api-php-client) [![Packagist](https://img.shields.io/packagist/dt/samoritano/linkedin-api-php-client.svg)](https://packagist.org/packages/samoritano/linkedin-api-php-client-v2) [![GitHub license](https://img.shields.io/github/license/samoritano/linkedin-api-php-client.svg)](https://github.com/samoritano/linkedin-api-php-client/blob/master/LICENSE.md)
[![Build Status](https://travis-ci.org/AgencyPMG/linkedin-api-php-client.svg?branch=master)](https://travis-ci.org/AgencyPMG/linkedin-api-php-client) [![Code Climate](https://codeclimate.com/github/AgencyPMG/linkedin-api-php-client/badges/gpa.svg)](https://codeclimate.com/github/AgencyPMG/linkedin-api-php-client) [![Packagist](https://img.shields.io/packagist/dt/AgencyPMG/linkedin-api-php-client.svg)](https://packagist.org/packages/AgencyPMG/linkedin-api-php-client-v2) [![GitHub license](https://img.shields.io/github/license/AgencyPMG/linkedin-api-php-client.svg)](https://github.com/AgencyPMG/linkedin-api-php-client/blob/master/LICENSE.md)


## Installation
Expand All @@ -10,7 +10,7 @@ You will need at least PHP 7.3. We match [officially supported](https://www.php.
Use [composer](https://getcomposer.org/) package manager to install the lastest version of the package:

```bash
composer require samoritano/linkedin-api-php-client-v2
composer require pmg/linkedin-api-php-client
```

Or add this package as dependency to `composer.json`.
Expand All @@ -22,10 +22,10 @@ Or add this package as dependency to `composer.json`.
Before you will get started, play visit to [LinkedIn API Documentation](https://docs.microsoft.com/en-us/linkedin/marketing/getting-started).
This will save you a lot of time and prevent some silly questions.

To start working with LinkedIn API, you will need to
get application client id and secret.
To start working with LinkedIn API, you will need to
get application client id and secret.

Go to [LinkedIn Developers portal](https://www.linkedin.com/developers/)
Go to [LinkedIn Developers portal](https://www.linkedin.com/developers/)
and create new application in section My Apps. Once your app has been approved, you will get a ClientId and ClientSecret, that you will use later.


Expand All @@ -48,26 +48,26 @@ $client = new Client(

#### Getting local redirect URL

To start linking process you have to setup redirect url.
To start linking process you have to setup redirect url.
You can set your own or use current one.
SDK provides you a `getRedirectUrl()` helper for your convenience:

```php
$redirectUrl = $client->getRedirectUrl();
```

We recommend you to have it stored during the linking session
We recommend you to have it stored during the linking session
because you will need to use it when you will be getting access token.

#### Setting local redirect URL
#### Setting local redirect URL

Set a custom redirect url use:

```php
$client->setRedirectUrl('http://your.domain.tld/path/to/script/');
```

#### Getting LinkedIn redirect URL
#### Getting LinkedIn redirect URL

In order of performing OAUTH 2.0 flow, you should get LinkedIn login URL.
During this procedure you have to define scope of requested permissions.
Expand All @@ -82,7 +82,7 @@ use LinkedIn\Scope;

// define scope
$scopes = [
Scope::READ_LITE_PROFILE,
Scope::READ_LITE_PROFILE,
Scope::READ_EMAIL_ADDRESS,
Scope::SHARE_AS_USER,
Scope::SHARE_AS_ORGANIZATION,
Expand All @@ -92,20 +92,20 @@ $loginUrl = $client->getLoginUrl($scopes); // get url on LinkedIn to start linki

Now you can take user to LinkedIn. You can use link or rely on Location HTTP header.

#### Getting Access Token
#### Getting Access Token

To get access token use (don't forget to set redirect url)

```php
$accessToken = $client->getAccessToken($_GET['code']);
```
This method returns object of `LinkedIn\AccessToken` class.
This method returns object of `LinkedIn\AccessToken` class.
You can store this token in the file like this:
```php
file_put_contents('token.json', json_encode($accessToken));
```
This way of storing tokens is not recommended due to security concerns and used for demonstration purpose.
Please, ensure that tokens are stored securely.
This way of storing tokens is not recommended due to security concerns and used for demonstration purpose.
Please, ensure that tokens are stored securely.

#### Setting Access Token

Expand All @@ -118,7 +118,7 @@ use LinkedIn\Client;

// instantiate the Linkedin client
$client = new Client(
'LINKEDIN_APP_CLIENT_ID',
'LINKEDIN_APP_CLIENT_ID',
'LINKEDIN_APP_CLIENT_SECRET'
);

Expand All @@ -132,7 +132,7 @@ $accessToken = new AccessToken($tokenData['token'], $tokenData['expiresAt']);
$client->setAccessToken($accessToken);
```

#### Performing API calls
#### Performing API calls

All API calls can be called through simple method:

Expand Down Expand Up @@ -211,25 +211,3 @@ Some private API access there.
```php
$client->setApiRoot('https://api.linkedin.com/v2/');
```

##### ~Image Upload~ --> OBSOLETE (This part needs an update)

I assume you have to be LinkedIn partner or something like that.

Try to upload image to LinkedIn. See [Rich Media Shares](https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/rich-media-shares)


```php
$filename = '/path/to/image.jpg';
$client->setApiRoot('https://api.linkedin.com/');
$mp = $client->upload($filename);
```

## Contributing

Please, open PR with your changes linked to an GitHub issue.
You code must follow [PSR](http://www.php-fig.org/psr/) standards and have PHPUnit tests.

## License

[MIT](LICENSE.md)
40 changes: 7 additions & 33 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "samoritano/linkedin-api-php-client",
"name": "pmg/linkedin-api-php-client",
"description": "This package is an SDK for using LinkedIn V2 Marketing API. You can use it for managing Company Pages in this social network",
"type": "library",
"keywords": [
Expand All @@ -9,43 +9,17 @@
"social", "rest", "api", "client", "social network", "auth", "authorization",
"wrapper", "integration", "platform"
],
"homepage": "https://github.com/samoritano/linkedin-api-php-client",
"homepage": "https://github.com/AgencyPMG/linkedin-api-php-client",
"require": {
"php": ">=7.3",
"php": "^7.4 || ^8.0",
"ext-curl": "*",
"guzzlehttp/guzzle": "^6.3"
"guzzlehttp/guzzle": "^7.3.0"
},
"license": "MIT",
"authors": [
{
"name": "Samori Bokokó",
"email": "samori@bokokode.com",
"homepage": "https://bokokode.com/",
"role": "Developer"
},
{
"name": "Philipp Tkachev",
"email": "philipp@zoonman.com",
"homepage": "http://www.zoonman.com/",
"role": "Developer"
},
{
"name": "Aleksey Salnikov",
"email": "me@iamsalnikov.ru",
"homepage": "http://iamsalnikov.ru/",
"role": "Developer"
},
{
"name": "Daniel J. Post",
"homepage": "http://danieljpost.info/",
"role": "Developer"
}

],
"support": {
"docs": "https://github.com/samoritano/linkedin-api-php-client/blob/master/README.md",
"source": "https://github.com/samoritano/linkedin-api-php-client",
"issues": "https://github.com/samoritano/linkedin-api-php-client/issues"
"docs": "https://github.com/AgencyPMG/linkedin-api-php-client/blob/master/README.md",
"source": "https://github.com/AgencyPMG/linkedin-api-php-client",
"issues": "https://github.com/AgencyPMG/linkedin-api-php-client/issues"
},
"autoload": {
"psr-4": {"LinkedIn\\": "src/"}
Expand Down
Loading