Coder Social home page Coder Social logo

php-upwork's Introduction

PHP bindings for Upwork API (OAuth1)

License Latest Stable Version Package version Build status Monthly downloads

Introduction

This project provides a set of resources of Upwork API from http://developers.upwork.com based on OAuth 1.0a.

Features

These are the supported API resources:

  • My Info
  • Custom Payments
  • Hiring
  • Job and Freelancer Profile
  • Search Jobs and Freelancers
  • Organization
  • Messages
  • Time and Financial Reporting
  • Metadata
  • Snapshot
  • Team
  • Work Diary
  • Activities

License

Copyright 2015 Upwork Corporation. All Rights Reserved.

php-upwork is licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SLA

The usage of this API is ruled by the Terms of Use at:

https://developers.upwork.com/api-tos.html

Application Integration

To integrate this library you need to have:

  • PHP >= 5.3.0
  • OAuth Extension installed (optional), we recommend using official pecl extension, but in case you want to use your own library, you need to drop line 'ext-oauth' from composer json, or do not use composer, which is also optional. In that case, you need to setup the 'authType' parameter in your configuration options. The source contains an oauth-php library that can be used as alternative. See more in the AuthTypes directory if you want to create an authentication layer for your own client library.
  • Composer installed (optional)

Example

In addition to this, a full example is available in the example directory. This includes console.php that gets an access token and requests the data for applications that are not web-based, and web.php for web-based applications. You can also find the console-own-auth-lib.php file to use your own php client together with this Upwork library.

There is also a composer.json included to use with Composer.

Composer

In order to easily integrate with your application we recommend using Composer to install the dependencies.

Below is a simple example of the composer.json file you can use:

{
    "name": "upwork/my-oauth-app",
    "require": {
        "upwork/php-upwork": "dev-master"
    }
}

Installation using Composer

Add upwork/php-upwork to your composer.json, simple example:

{
    "name": "my/my-oauth-app",
    "require": {
        "upwork/php-upwork": "v1.1.0" // note: the latest release is recommended
    }
}

run the following command /usr/local/bin/composer.phar update

the output should look similar to

Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing upwork/php-upwork (v1.1.0)
    Downloading: 100%         

Writing lock file
Generating autoload files

IMPORTANT: The library supports different OAuth clients, by default it requires PECL PHP extension (see more at http://www.php.net/oauth). Make sure it is installed. In case you don't want to use it, or you don't have the possibility to install it, you can use a preloaded php library, called oauth-php (read more in vendor-src/README).

copy vendor/upwork/php-upwork/example/console.php to the myapp.php if you have ext-oauth installed

or

copy vendor/upwork/php-upwork/example/console-own-auth-lib.php to myapp.php if you want to use preloaded php library as OAuth client

otherwise

  • check vendor/upwork/php-upwork/src/Upwork/API/AuthTypes/ and create your own wrapper for OAuth
  • copy vendor/upwork/php-upwork/example/console-own-auth-lib.php to myapp.php
  • after that update 'authType' property in the configuration section of myapp.php and specify the name of your handler.

NOTE: use web.php example if you are creating a web-based application.

open myapp.php and type the consumerKey and consumerSecret that you previously got from the API Center. That's all. Run your app as php myapp.php and have fun.

Installation by downloading sources

Download latest release from https://github.com/upwork/php-upwork/releases, let's say it is https://github.com/upwork/php-upwork/archive/v1.1.0.tar.gz, and extract it to vendor/upwork folder, located in the root directory of your application.

Create vendor/autoload.php, a possible simple variant could be:

require_once __DIR__ . '/upwork/php-upwork-1.1.0/src/Upwork/API/constants.php';

spl_autoload_register('UpworkVendorAutoloader');

function UpworkVendorAutoloader($_class)
{
    $path = __DIR__ . '/upwork/php-upwork-1.1.0/src/' . str_replace('\\', '/', $_class) . '.php';
    include_once $path;
}

open myapp.php and type the consumerKey and consumerSecret that you previously got from the API Center.

That's all. Run your app as php myapp.php and have fun.

php-upwork's People

Contributors

mnovozhylov avatar reedy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-upwork's Issues

How can I change entry point to https://www.upwork.com/gds/

Is there a way to change entry point from https://www.upwork.com/api/ to https://www.upwork.com/gds/?
As far as I can see use of https://www.upwork.com/api/ entry point is hard-coded.

I am trying to access:
https://developers.upwork.com/?lang=php#reports_get-earning-reports-for-a-freelancer
at present it returns only null for me (no errors or exceptions).

After enabling debug I learned that server returned '1534243642404404Wrong URL requested' and is trying to access https://www.upwork.com/api/finreports/v2/providers/{1234}/earnings.json

session tokens not set

In the config we see:

$config = new \Upwork\API\Config(
    array(
        'consumerKey'       => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx',  // SETUP YOUR CONSUMER KEY
        'consumerSecret'    => 'xxxxxxxxxxxxx',                  // SETUP YOUR KEY SECRET
        'accessToken'       => $_SESSION['access_token'],       // got access token
        'accessSecret'      => $_SESSION['access_secret'],      // got access secret
        'requestToken'      => $_SESSION['request_token'],      // got request token
        'requestSecret'     => $_SESSION['request_secret'],     // got request secret
        'verifier'          => $_GET['oauth_verifier'],         // got oauth verifier after authorization
        'mode'              => 'web',                           // can be 'nonweb' for console apps (default),
                                                                // and 'web' for web-based apps
//  'debug' => true, // enables debug mode. Note that enabling debug in web-based applications can block redirects
//  'authType' => 'MyOAuth' // your own authentication type, see AuthTypes directory
    )
);

but $_SESSION['access_token'] nor $_SESSION['access_secret'] are set yet,

Sending message didn't work

Solved with following pattern

        return $messages->sendMessageToRoom($company, $roomId, ['story' => json_encode([
            'message' => $message,
            'userId' => '~013e445f6cc6899b5f',
            'orgId' => 's9qfl3qgy6tzqpxp1y5n4g',
        ])]);

Workdiary::get() incorrectly overrides Client::get()

PHP Warning with message 'Declaration of 
Upwork\API\Routers\Workdiary::get($company, $username, $date, $params = Array)
should be compatible with 
Upwork\API\Client::get($url, $params = Array)'

in vendor/upwork/php-upwork/src/Upwork/API/Routers/Workdiary.php:81

Suggest renaming the method to getByCompany or getByCompanyAndUsername.

Or alternatively, don't extend Client. The calls are being made to $this->_client and not $this, so I don't see the reason for it.

Error in Engagement file

There is an error in the file: Upwork/API/Routers/Activities/Engagement.php line 55
it's being used var $engagement_ref, but in the function parameter, var is called $engagementRef, so I always get: undefined var engagement_ref.

This is the original function:

public function getSpecific($engagementRef)
{
ApiDebug::p(FUNCTION);
$response = $this->_client->get('/tasks/v2/tasks/contracts/' . $engagement_ref);
ApiDebug::p('found response info', $response);
return $response;
}

and it should be

public function getSpecific($engagementRef)
{
ApiDebug::p(FUNCTION);
$response = $this->_client->get('/tasks/v2/tasks/contracts/' . $engagementRef);
ApiDebug::p('found response info', $response);
return $response;
}

ouath_call back option

can't set oauth_callback option in config for callback url if not set in api setting

$client = new \Upwork\API\Client($config);
$client->getRequestToken();

Documentation woefully simplified/incomplete

https://github.com/upwork/php-upwork/blob/master/README.md#installation-by-downloading-sources

Says copy https://github.com/upwork/php-upwork/blob/master/example/console.php to myapp.php

Then "open myapp.php and type the consumerKey and consumerSecret that you previously got from the API Center."

This isn't very helpful. As this point, you'll need to take the malformed URL (see also #16 ) and put it into a web browser, login, and then give the code back......

But then it's all kinda useless trying to use the upwork api via a command line, if it needs interactivity. You can't run it via cron or something, unless, you can save the "logged in ness" somehow

Oauth included library exceptions.

I'm getting these two erros while trying to connect with my API key & secret via the shipped oauth component:

Fatal error: Uncaught exception 'OAuthException2' with message 'Unexpected result from the server "https://www.upwork.com/api/auth/v1/oauth/token/access" (401) while requesting an access token' in /home/ubuntu/workspace/vendor/upwork/php-upwork/vendor-src/oauth-php/library/OAuthRequester.php on line 258

OAuthException2: Unexpected result from the server "https://www.upwork.com/api/auth/v1/oauth/token/access" (401) while requesting an access token in /home/ubuntu/workspace/vendor/upwork/php-upwork/vendor-src/oauth-php/library/OAuthRequester.php on line 258

Am I doing anything wrong?

This is the debug output:

> preparing Client.
> starting Upwork\API\AuthTypes\AbstractOAuth authentication.
> authing Client.
> running auth process in Upwork\API\AuthTypes\AbstractOAuth.
> query request token from server.
> get OAuth instance.
> create full url, based on global constant.
> url, dump: 'https://www.upwork.com/api/auth/v1/oauth/token/request'.
> create full url, based on global constant.
> url, dump: 'https://www.upwork.com/api/auth/v1/oauth/token/access'.
> got request token info, dump: array (
  'authorize_uri' => '/services/api/auth',
  'token' => '[REMOVED]',
  'token_secret' => '[REMOVED]',
).
> create full url, based on global constant.
> url, dump: 'https://www.upwork.com/services/api/auth'.
> found [nonweb] mode, need to autorize application manually.
> requesting access token.
> get OAuth instance.
> create full url, based on global constant.
> url, dump: 'https://www.upwork.com/api/auth/v1/oauth/token/request'.
> create full url, based on global constant.
> url, dump: 'https://www.upwork.com/api/auth/v1/oauth/token/access'.

Any feedback would be helpful.

Many thanks,
VG

How to get this /vendor/autoload.php

I am trying to integrate it but it is giving the error of require DIR . '/../../../vendor/autoload.php'; is missing. Please suggest me any usefull tip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.