How to test rest api written in codeigniter using URL manually - php

How can I test my rest api via URL?
I copied code from https://github.com/alexmarton/RControl and it only have instruction for get method.
So far what I've tried are :
http://test/api/blog/delete/2?format=json&X-API-KEY=1234
http://test/api/delete/2?format=json&X-API-KEY=1234

You can use Postman to test your APIs with manual data.

Related

Vtiger Query webservice returnes 403 access forbidden error in postman

I am new to vtiger and recently I tried working with third party API integration of vtiger where we can have a query webservice. I tried following API in Postman
http://myurl/webservice.php?operation=query&sessionName=63c67873606f00c2d94fa&query=select count(*) from Leads where Leadid = 1
which is giving 403 error. Also please let me know where to create a webservice in vtiger.
You have to authenticate:
First, get a challenge token:
GET /webservice.php?operation=getchallenge&username=<USERNAME> HTTP/1.1
Then use that token, together with a username and the accesskey of that user (not to be confused with the user's password) to login:
POST /webservice.php HTTP/1.1
operation=login
username=<USERNAME>
accessKey=md5(TOKENSTRING + <ACCESSKEY>) // Note: accessKey= K here is capitalized.
Notice that the concatenation of TOKENSTRING and ACCESSKEY need to be encoded using the md5 function. I recommend using php to do that operation because I've had problems using online encoders.
About the second question, take a look at the folder include/Webservices. Many of the files under that folder are ws functions and you have to create something similar. After created, you have to register
the function by calling vtws_addWebserviceOperation() and
each parameter of the function by calling vtws_addWebserviceOperationParam.
Both of the above functions are defined under /include/Webservices/Utils.php
source: https://community.vtiger.com/help/vtigercrm/developers/third-party-app-integration.html

Pushwoosh: Set Badge with PHP API

I'm using a paid Pushwoosh Account in order to send programmatically push-notifications to my users.
I've implemented the Pushwoosh PHP SDK and everything works great, but I'm not able to set a Notification-Badge on iOS devices as seen on the following image:
My code so far is:
$devicesArr[] = ...
$pushwoosh = Pushwoosh::create()
->setApplication('79XXX-9CXXX')
->setAuth('Wkf...2C8');
//Create the Message
$request = CreateMessageRequest::create()
->addNotification(Notification::create()
->setContent('A new workout is available!')
->setDevices($devicesArr));
//Call the REST Web Service
$response = $pushwoosh->createMessage($request);
I tried to use the ->setBadge(5) method according to this page but this also does not work:
$request = SetBadgeRequest::create()
->setBadge(1)
->setHwid('18D...1AF');
Do you know how I can achieve my goal?
I can't reproduce this on Cordova Sample (https://github.com/Pushwoosh/pushwoosh-phonegap-cordova-sample/tree/master/Phonegap-iOS-Android-WP), can you share a simple sample?
Are you sure the app is closed when you receive push with badge?
Per the docs, this is not the method you use to set the badge number on the device.
Important
This method IS NOT used to update the badge value on the device.
Instead please use /createMessage request with the "ios_badges" parameter.
http://docs.pushwoosh.com/docs/setbadge

How to retrieve data from Rdio API using PHP?

I can't get the Rdio PHP API to work (i.e. retrieve some meaningful data). I need to write a simple function for fetching info about track / album stored in a ShortCode.
I am using PHP version of this:
https://github.com/rdio/rdio-simple
And this is my PHP code:
require_once 'rdio.php';
$rdio = new Rdio(array("MyClientID", "MyClientSecret"));
$request = $rdio -> call("getObjectFromShortCode", array("short_code" => "SomeShortCode"));
return $request;
However, when I do print_r() on the function output, there is no output at all.
I am a bit confused about how to initialize the API and get the response. The Rdio developer documentation itself doesn't give me a clue when trying to resolve the issue.
Would you mind telling me how to properly retrieve data using PHP from the API?
The Rdio PHP library currently doesn't support OAuth 2.0. You can try using a generic OAuth 2.0 library to make requests.

how to use GET to obtain info from a URL

I'm a php programmer but I'm new to APIs.
I would like to run a mysql query to get info from an XML document from madmimi.com.
documentation from madmimi.com says
GET http://madmimi.com/audience_lists/lists.xml will return the data I need. I've created a php file and connected to their API using
require(dirname(FILE) . '/MadMimi.class.php');
$mailer = new MadMimi('username', 'password');
but I don't understand how to use GET to connect to the URL and display the XML info?
What do I need to do?
All http api interaction is hidden to you behind their library. You can use it's methods to grab objects, like this to lists:
$mailer->Lists();
There is no complete documentation, but you can read raw code to search urls, described in API for finding appreciated methods.
You can use curl to get the response from the 3rd party api. Have a look at this answer:
https://stackoverflow.com/a/5159513/1369567
Based upon the code in answer given at that link, you may need to the code to match your request. E.g:
/* Script URL */
$url = 'http://madmimi.com/audience_lists/lists.xml';
/* $_GET Parameters to Send */
$params = array('username' => '*your api username*', 'password' => '*your api password*');

Twitter API post statuses/filter with Twitter OAuth Class

I keep getting error code 34 (Sorry, this page does not exist) when attempting to make a post request to the statuses/filter method with the abraham twitteroauth class (https://github.com/abraham/twitteroauth). Following authentication (that's working fine) my request is simple:
$filter = $twitteroauth->post('statuses/filter',array('track' => 'seo'));
I have other calls working but even when I isolate this on a separate instance of the site, I'm only receiving the "Sorry, that page does not exist" error.
Any help would be appreciated.
TwitterOAuth does not currently support the Streaming APIs. You can try the method that #JohnC suggests but I don't know if it will actually work.
Phirehose is the PHP library I recommend for use with the Streaming APIs.
The statuses/filter call uses a different URL to many of the other API calls - using stream.twitter.com instead of api.twitter.com. The library you are using appears to be hardcoded to only use api.twitter.com, so this could be the source of your problem. You can either change the URL for that call:
$twitteroauth->host = "https://stream.twitter.com/1/";
$filter = $twitteroauth->post('statuses/filter',array('track' => 'seo'));
Or if you use the full URL it will override the default (probably the best way if you make multiple calls to the $twitteroauth class):
$filter = $twitteroauth->post('https://stream.twitter.com/1/statuses/filter.json',array('track' => 'seo'));

Categories