Narnoo / Narnoo-PHP-API-Library

This is a library for Narnoo's API in PHP
http://www.narnoo.com
1 stars 0 forks source link

API Library PHP / ASP #1

Closed Narnoocom closed 12 years ago

Narnoocom commented 12 years ago

Hi Dayi,

I'm still a little behind in the social media side of things. The hold up at the moment is FUSE for S3. We have to fuse the file systems together so that the API's reads our files as if locally and not via a http link. I have it going but I don't think its very stable. Give me another 2 days.

I do have another little project that needs doing. I have that API well into development now. I would like to make libraries in different languages (PHP / ASP), that interact with the API. I'm not a programer but I started playing around with making a little PHP library for the API yesterday. I have uploaded it here. Just wondering if you wanted to do some of that library in the mean time?

Every week from now on we will be adding new functions so it will be ongoing until its done. The purpose of the libraries is to make integration into clients sites as simple as possible. If we can make the libraries we can do a lot of the repetitive coding for clients.

Let me know what you think.

James

cnlangzi commented 12 years ago

thanks. I am glad to implement them with you. so just show me function spec.

Narnoocom commented 12 years ago

Below is all the information that I have for this so far. I have been working off this..

A sample operator ID to use is '39'..

I am sending you distributor API working detail. Please check and let me know if any feedback.

Sample API link.

1) Add Operator - > http://devapi.narnoo.com/get_result_from_api.php?op_id=74&action=addOperator You can add operator from this API link. This link is having the op_id and action. Action parameter define the what action you want to perform.

2) Delete Operator -> http://devapi.narnoo.com/get_result_from_api.php?op_id=74&action=deleteOperator

3) Get Images -> http://devapi.narnoo.com/get_result_from_api.php?op_id=39&action=getImages

4) Get Videos -> http://devapi.narnoo.com/get_result_from_api.php?op_id=39&action=getVideos

get_result_from_api.php page is having few lines of code. Distributor can use this code into their website page. They will have to put app key & secret code. If app key & secret key authenticate then response will be generate otherwise it will return error. If distributor will put anything wrong in the parameter then error will produce.

By default response type is XML. If pass response type in the link like as http://devapi.narnoo.com/get_result_from_api.php?op_id=39&action=getImages&response_type=json then output response will be in JSON format.

Below is code detail.

<?php $app_key = "1000000000"; // Distributor App Key which they can get from their control panel after add application $secret_key = "6af234c9bc0361452797fc14a5cc856ece4a5908"; // Distributor SecretKey which they can get from their control panel after add application

// action may be (addOperator or deleteOperator or getImages or getVideos) $action = (trim($_GET['action'])!='') ? trim($_GET['action']) : "addOperator"; $operator_id = (trim($_GET['op_id'])!='') ? trim($_GET['op_id']) : 1; $response_type = (trim($_GET['response_type'])!='') ? trim($_GET['response_type']) : "xml"; // xml OR json $data = array('app_key' => $app_key, 'secret_key' => $secret_key, 'response_type' => $response_type, 'action' => $action, 'operator_id' => $operator_id);

$xmlUrl = 'http://devapi.narnoo.com/xml.php'; // XML feed file/URL $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_HTTPGET, 0); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_FAILONERROR, 0); curl_setopt($ch, CURLOPT_URL, $xmlUrl); $returned = curl_exec($ch); curl_close ($ch);

?>

This output they can parse and display output into their format as they want into their page.

You can copy this code and put into another website server and run page then you will get output.

cnlangzi commented 12 years ago

Clear now. You want to wrap your api methods, and provider it to your users as API SDK. I will check it, and try to get it run on my local host.

Narnoocom commented 12 years ago

Correct.

You'll need the app_key & secret_key from the previous message.

I just want to make the SDK do a lot of the grunt as far as coding goes. That way client can integrate API easily into their site.

On Monday, February 13, 2012, Dayi Chen < reply@reply.github.com> wrote:

Clear now. You want to wrap your api methods, and provider it to your users as API SDK. I will check it, and try to get it run on my local host.


Reply to this email directly or view it on GitHub:

https://github.com/Narnoo/Narnoo-PHP-API-Library/issues/1#issuecomment-3936203

cnlangzi commented 12 years ago

should I implement all methods listed in API-Functions.pdf?

cnlangzi commented 12 years ago

And should it support many response format? the xml response is supported in your code.but json response is not implemented yet. And jsonp response only should be implemented in Javascript SDK.

Narnoocom commented 12 years ago

Here is a list of all functions completed to date - we will be adding all from the functions PDF however, not all are completed.

addOperators deleteOperators getImages getVideos getBrochures getVideoDetails getBrochureDetails getAlbums getAlbumImages getProducts getProductDescriptions

More are added daily now.

Examples of last ones this morning..

i.e - op_id=39&album=sample&action=getAlbumImages Fixed Please check http://humsabkavideo.com/production/ecom/NarNoo_API/get_result_from_api.php?op_id=39&album=sample&action=getAlbumImages&response_type=xml

OR http://humsabkavideo.com/production/ecom/NarNoo_API/get_result_from_api.php?op_id=39&album=test&action=getAlbumImages&response_type=xml OR (No album given then all albums images will be listed in response of that operator) http://humsabkavideo.com/production/ecom/NarNoo_API/get_result_from_api.php?op_id=39&action=getAlbumImages&response_type=xml


Please check getVideos http://humsabkavideo.com/production/ecom/NarNoo_API/get_result_from_api.php?op_id=39&action=getVideos&response_type=xml

Please check getVideoDetails (if not provide video_id then all videos will be shown) http://humsabkavideo.com/production/ecom/NarNoo_API/get_result_from_api.php?op_id=39&action=getVideoDetails&video_id=413&response_type=xml

Please check getBrochures http://humsabkavideo.com/production/ecom/NarNoo_API/get_result_from_api.php?op_id=39&action=getBrochures&response_type=xml

Please check getSingleBrochure (if not provide brochure_id then all brochures will be shown) http://humsabkavideo.com/production/ecom/NarNoo_API/get_result_from_api.php?op_id=39&action=getSingleBrochure&brochure_id=360&response_type=xml

Please check getProducts http://humsabkavideo.com/production/ecom/NarNoo_API/get_result_from_api.php?op_id=39&action=getProducts&response_type=xml Please check getProductDescription based on product title (if no product title provide then all products description will be shown as response) http://humsabkavideo.com/production/ecom/NarNoo_API/get_result_from_api.php?op_id=39&action=getProductDescription&product_title=Narnoo%20Platform&response_type=xml

The response formats are XML and JSON. JSONP should only be in Javascript SDK - correct. JSONP isn't finished yet. I know its just a callback on a JSON request so shouldn't be long.

JSON has been implement. You just have to pass json as the response_type. i.e.

http://humsabkavideo.com/production/ecom/NarNoo_API/get_result_from_api.php?op_id=39&action=getVideos&response_type=jsonhttp://humsabkavideo.com/production/ecom/NarNoo_API/get_result_from_api.php?op_id=39&action=getVideos&response_type=xml

On Wed, Feb 15, 2012 at 9:06 AM, Dayi Chen < reply@reply.github.com

wrote:

And should it support many response format? the xml response is supported in your code.but json response is not implemented yet. And jsonp response only should be implemented in Javascript SDK.


Reply to this email directly or view it on GitHub:

https://github.com/Narnoo/Narnoo-PHP-API-Library/issues/1#issuecomment-3971651

cnlangzi commented 12 years ago

wow, got it now.

The API style is different with original design in API.pdf. For now it is traditional web request(url?response_type=json&id=11&action=getImages) instead of restful service(/images/json/11).

Narnoocom commented 12 years ago

Yeah a little different now.

On 15/02/2012, at 10:42, Dayi Chenreply@reply.github.com wrote:

wow, got it now.

The API style is different with original design in API.pdf. For now it is traditional web request(url?response_type=json&id=11&action=getImages) instead of restful service(/images/json/11).


Reply to this email directly or view it on GitHub: https://github.com/Narnoo/Narnoo-PHP-API-Library/issues/1#issuecomment-3972997

Narnoocom commented 12 years ago

Just to let you know that the web requests in the examples i sent through are for that particular website. Those requests are being passed through to the CURL method in the script. But i'm sure you have seen this part.

On Wed, Feb 15, 2012 at 11:10 AM, James Wells wellzie.james@gmail.comwrote:

Yeah a little different now.

On 15/02/2012, at 10:42, Dayi Chen< reply@reply.github.com> wrote:

wow, got it now.

The API style is different with original design in API.pdf. For now it is traditional web request(url?response_type=json&id=11&action=getImages) instead of restful service(/images/json/11).


Reply to this email directly or view it on GitHub:

https://github.com/Narnoo/Narnoo-PHP-API-Library/issues/1#issuecomment-3972997

cnlangzi commented 12 years ago

thanks for info.

cnlangzi commented 12 years ago
  1. I cannot find how to add an application on narnoo.com.
  2. You have two remote urls(http://devapi.narnoo.com/xml.php and http://devapi.narnoo.com/get_result_from_api.php). What is different? seems like xml.php is protected, and get_result_from_api.php is public(anonymous)
cnlangzi commented 12 years ago
  1. do you have a document for all implemented api method(e.g name, parameters and return object).
Narnoocom commented 12 years ago

Documentation:

You will have to bare with me on documentation.

It's coming but the functions are being finished daily so we are traveling along side with the development. All the links i have sent through have parameters and display return objects.

New App User:

I'll have it working on the devsite in 24hrs. -> but it is under Accounts heading in menu.

However, you can use the app_key and secret_key I sent through earlier. This is for the demo account - details are:

Login Details: Holidays Password: ChosenLine

  1. You have two remote urls - the difference:

http://devapi.narnoo.com/xml.php This the URL to our REST Calls from Narnoo server.

http://devapi.narnoo.com/get_result_from_api.php This is just a page on a site.. You could take this page and put it on your localhost and it would work. It contains the script that interacts with the API.

That page would include our PHP SDK

On Thu, Feb 16, 2012 at 7:25 AM, Dayi Chen < reply@reply.github.com

wrote:

  1. do you have a document for all implemented api method(e.g name, parameters and return object).

Reply to this email directly or view it on GitHub:

https://github.com/Narnoo/Narnoo-PHP-API-Library/issues/1#issuecomment-3989447

cnlangzi commented 12 years ago

Ok. I will review your php file to get API detail information.