Coder Social home page Coder Social logo

rest-api-client-php's People

Contributors

choiceforyou avatar phradion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rest-api-client-php's Issues

Error on creating contact.

I am creating contact using following code.

$newc = new Contact;
$newc->setDisplayName('Ashish10');
$newc->setFamilyName('Namdeo10');
$newc->setGivenName('AKN11');
$newc->setEmailAddress('[email protected]');
$newc->setGroup(451121);
$newc->setMsisdn('919891xxxxxx');
$rest->save($newc);

But its throwing Internal Server Error on smsglobal script.
[content:protected] => {"error":"Undefined index: group on line 37 in /var/www/api/rest-api/src/Rest/Resource/Field/Validator/Unique.php"}
[handle:protected] => Resource id #2
[headers:protected] => HTTP/1.0 500 Internal Server Error

Is this issue in client script or on smsglobal script.

Retrieving resource id after POST/PATCH

While trying to post a new sms message, i was relying on returning $sms->getId(), as per your example in the README.md, but it was coming back as 0.

After a little investigation (read: hours of var_dumps), i noticed a few issues with the way the id was being extracted from the response.

File: Smsglobal/RestApiClient/RestApiClient.php
Line: 250

$id = (int) substr($id, strrpos('/', $id) + 1, -1);

The first issue is that the arguments for the function strrpos are in the wrong order. It should be strrpos($id, '/') (see php.net/strrpos).

Secondly, the final parameter (-1) is unnecessary as the trailing slash is already removed on line 248. (Alternatively, you could use rtrim($id, '/') to achieve the same result there)

The resulting code for line 250 should look like this:

$id = (int) substr($id, strrpos($id, '/') + 1);

P.S. Thank you for providing this library, it made it a whole lot easier to get started with the API :)

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.