Mobile Native 와 Web Html의 상호 송수신 통신

 

 

MainActivity.java

더보기

WebView myWebView;

final public Handler handler = new Handler(); //android.os.Handler

@Override

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    Toolbar toolbar = findViewById(R.id.toolbar);

    setSupportActionBar(toolbar);

 

    myWebView = (WebView) findViewById(R.id.webView1);

    WebSettings setting = myWebView.getSettings();

 

    setting.setJavaScriptCanOpenWindowsAutomatically(true);

    setting.setJavaScriptEnabled(true);//자바스크립트 허용

    setting.setAllowFileAccess(true);//false => security reason

    setting.setAllowContentAccess(true);

    setting.setDomStorageEnabled(true);

 

    myWebView.addJavascriptInterface(new JsJavaBridge(this, myWebView), "oInterface");

    setting.setBuiltInZoomControls(true);

    setting.setDefaultFontSize(20);

    setting.setPluginState(WebSettings.PluginState.OFF);//no flash

    //load test.html from the assets folder

 

    myWebView.loadUrl("file:///android_asset/test.html");

 

    myWebView.setWebViewClient(new CustomWebViewClient());

    myWebView.setWebViewClient(new CustomWebViewClient(){

        public void onPageFinished(WebView viewString weburl){

            Log.d("PJM:""onPageFinished:"+weburl);

            String sJs = "javascript:testDraw('onPageFinished',1)";

 

            // view.loadUrl("javascript:alert('Javascript fire!');");

            //alert명령은 안됨.

            view.loadUrl(sJs);

    }

    });

}

// Navigation WebView with Back Button

@Override

public boolean onKeyDown(int keyCode, KeyEvent event) {

    if ((keyCode == KeyEvent.KEYCODE_BACK) && this.myWebView.canGoBack()) {

    this.myWebView.goBack();

    return true;

    }

 

    return super.onKeyDown(keyCode, event);

}

 

public void javaCallHtml(int iArg){

    // Toast.makeText()

    Log.d("PJM","javaCallHtml : " + String.valueOf(iArg));

    // myWebView.loadUrl("javascript:testDraw()");

    String sJs = "javascript:testDraw('javaCallHtml', 3)";

    // https://nicgoon.tistory.com/192 참고

    //webview와 android는 비동기 상태이므로 쓰레드로 넣어전달해 주어야 한다.

    handler.post(new Runnable() {

        @Override

        public void run() {

        myWebView.loadUrl(sJs);

        }

        });

}

 

JsJavaBridge.java : html call java method

더보기

import android.util.Log;

import android.webkit.JavascriptInterface;

import android.webkit.WebView;

 

public class JsJavaBridge {

 

MainActivity mainActivity;

WebView webView;

public JsJavaBridge(MainActivity mainActivityWebView webView)  {

    this.mainActivity = mainActivity;

    this.webView = webView;

}

 

@JavascriptInterface

public void setResult(int val){

    Log.d("PJM","JavaScriptHandler.setResult is called : " + val);

    this.mainActivity.javascriptCallFinished(val);

}

@JavascriptInterface

public void calcSomething(int xint y){

 

    Log.d("PJM","calcSomething:" + String.valueOf(x) + " * " + String.valueOf(y));

    this.mainActivity.javaCallHtml( (x * y));

}

}

 

test.html

더보기

<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>WebView1</title>
<meta forua="true" http-equiv="Cache-Control" content="max-age=0"/>
</head>

<body style="background-color:#212121">
<script type="text/javascript">
function testEcho(arg){
document.write(arg);
}

function testAlert(arg)
{
setTimeout(function() {
document.write(arg);
},5000);

}

 

function testDraw(arg, seq){
document.getElementById('divTag').innerHTML =arg+ seq;
}

</script>
</body>
<input type="button" onclick="window.oInterface.doSomething(1,2)" value="html call java method" />
<br>
<input type="button" onclick="testDraw('html onclick script', 2)" value="html drawing" />
<br>
<div id="divTag"></div>
</html>

 

시연)

파이선 참고자료

 

documents : https://docs.python.org/ko/3/tutorial/index.html

formatters : https://pyformat.info/

w3강좌 : https://www.w3schools.com/python/python_getstarted.asp

예제 300 : wikidocs.net/book/922

'프로그래밍' 카테고리의 다른 글

Python 사용시 SSL에러관련  (0) 2020.08.05

Python
pip사용시 SSL에러관련

에러내용)
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)'))': /simple/python-docx/
Could not fetch URL https://pypi.org/simple/python-docx/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/python-docx/ (Caused
by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)'))) - skipping
ERROR: Could not find a version that satisfies the requirement python-docx (from versions: none)
ERROR: No matching distribution found for python-docx

해결방안)
--trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org
를 명령어 끝에 붙여서 수행하면 진행됨

예) pip install python-docx --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org

'프로그래밍' 카테고리의 다른 글

python기초  (0) 2020.09.09

 

 

프로젝트진행 방법으로 칸보드 이용하기

개인 프로젝트를 하면서 트레이닝용으로 칸보드를 이용해보고 있다.

todo, 일정관리용으로 진행해보고 있음.

PM, 비즈니스분석, 개발자 입장으로 칸반을 본다면 어떤 얘기들이 나올까? 

결과는 다음에......

 

php 7.2... 이상 버전에서 아래 url로 kanboard 다운로드하여 웹 install진행

 

 

https://kanboard.org/

 

Kanban Project Management Software - Kanboard

Kanboard has a very simple query language that offers the flexibility to find tasks in no time. Dynamically apply custom filters on the board to find what you need. Search by assignees, description, categories, due date, etc.

kanboard.org

 

'프로그래밍 > PHP' 카테고리의 다른 글

WAMP 설치  (0) 2020.05.26
Open Api Request / Response Schema구성&실행  (0) 2018.08.19
curl kakao open api 도서검색  (0) 2018.08.10
curl kakao open api 이미지검색하기  (0) 2018.08.06
curl kakao open api사용하기  (0) 2018.08.05

WAMP란 마이크로소프트 윈도우 환경에서 PHP, MySQL, Apache를 사용할 수 있는 환경을 만들어주는 소프트웨어이다.

installer : https://bitnami.com/stack/wamp/installer

 

Install WAMP, Download WAMP

show MD5 259106612657e5fa49e8254990dff21a SHA1 6264bc05d86181e9d95a1ae4993a781cbb6fa5d3 SHA256 c8f4279d106ddae7424977cb045a81a08893d6f04e723c0451d92368aff9f3db

bitnami.com

다운로드 설치후 

Bitnami Wamp Stack 이란 원도우폼 형식의 operation 화면을 볼수 있다.

여기서 apache web server, mysql database를 시작/종료 및 설정파일 수정할 수 있다.

최신버전으로 WAMP설치시 PHP는 7.2.~~ 버전

 

상세 내역을 db화 할때 full text가 encoding된 html text일 수 있다

등록할때 보통 text를 escape하거리 html encoding하여 db에 등록하곤한다.


angularjs 사용에서 db에 들어있는 html text를 화면에 바인딩 하려면 ng-bind-html을 이용한다.

html로 표현하며 바인딩하기


encoding된 html text를 ng-bind-html 로 바인딩 하면 decoding하여 표현만 하고 html이 적용된 모습으로 화면에 표현되진 않는다.

그래서

ng-bind-html을 이용할때는 decoding된 html full text를 $scope 영역에 담고 사용한다.




<p>상품상세 부분 html encoded text will be added</p>

<ol>

<li>상품의 상세정보를 기술한다</li>

<li>이미지를 첨부할 수 있다<img src="https://t1.daumcdn.net/cfile/tistory/996B28455C1F6FB206" alt="" width="530" height="808" /></li>

<li>기타 <a href="http://doitforyou.co.kr">링크를</a> 추가할 수 있따.</li>

</ol>


==>ENCODED HTML

&lt;p&gt;상품상세 부분 html encoded text will be added&lt;/p&gt;

&lt;ol&gt;

&lt;li&gt;상품의 상세정보를 기술한다&lt;/li&gt;

&lt;li&gt;이미지를 첨부할 수 있다&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/996B28455C1F6FB206&quot; alt=&quot;&quot; width=&quot;530&quot; height=&quot;808&quot; /&gt;&lt;/li&gt;

&lt;li&gt;기타 &lt;a href=&quot;http://doitforyou.co.kr&quot;&gt;링크를&lt;/a&gt; 추가할 수 있따.&lt;/li&gt;

&lt;/ol&gt;'


=>



c#을 사용하고 있어

결과 dataset의 특정필드를 htmldecode시켜서 VIEW페이지로 리턴한다.


        private void getProdPrice(String sParam1)

        {

            bivrProdM oProd = new bivrProdM();


            DataSet dsResult = null;


            dsResult = oProd.GetProdPrice(sParam1);


            dsResult.Tables[0].Rows[0]["CONTENTS1"] = Server.HtmlDecode(dsResult.Tables[0].Rows[0]["CONTENTS1"].ToString());


            String jsonString = JsonConvert.SerializeObject(dsResult);

            Response.Write(jsonString);

        }




html page

 <div class="col-xs-12 col-sm-10 blog-content">

                                <a href="#"><img class="img-responsive img-blog" check-image ng-src="{{imageUrl}}" width="100%" alt="" /></a>

                                <h2><a href="blog-item.html">Consequat bibendum quam liquam viverra</a></h2>

                                <h3>Curabitur quis libero leo, pharetra mattis eros. Praesent consequat libero eget dolor convallis vel rhoncus magna scelerisque. Donec nisl ante, elementum eget posuere a, consectetur a metus. Proin a adipiscing sapien. Suspendisse vehicula porta lectus vel semper. Nullam sapien elit, lacinia eu tristique non.posuere at mi. Morbi at turpis id urna ullamcorper ullamcorper.</h3>

                                <a class="btn btn-primary readmore" href="blog-item.html">Read More <i class="fa fa-angle-right"></i></a>

                                htmlTest : [{{AddHtmlData}}] vs. [<span ng-bind-html="AddHtmlData"></span>]

                            </div>





--------------------------------------------

angularjs사용하기 위한 스크립트

--------------------------------------------



<script src="https://code.angularjs.org/1.7.6/angular.min.js"></script>

<script src="https://code.angularjs.org/1.7.6/angular-sanitize.min.js"></script>

    <script>


        var app = angular.module('myApp', ['ngSanitize']);


.......


   $http.get("/View/getProductDetails.aspx?oP=" + oParam1)

                .then(function (response) {

                    $scope.PDTLNAME = response.data.Table[0].PDTLNAME;

                    $scope.PINITAMT = response.data.Table[0].PINITAMT;

                    $scope.PTAXAMT = response.data.Table[0].PTAXAMT;

                    $scope.CONTENTSTITLE = response.data.Table[0].CONTENTSTITLE;

                   var  CONTENTS1= response.data.Table[0].CONTENTS1;

                    


                  //  var aa = "&lt;p&gt;상품상세 부분 html encoded text will be added&lt;/p&gt;&lt;ol&gt;&lt;li&gt;상품의 상세정보를 기술한다&lt;/li&gt;&lt;li&gt;이미지를 첨부할 수 있다&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/996B28455C1F6FB206&quot; alt=&quot;&quot; width=&quot;530&quot; height=&quot;808&quot; /&gt;&lt;/li&gt;&lt;li&gt;기타 &lt;a href=&quot;http://doitforyou.co.kr&quot;&gt;링크를&lt;/a&gt; 추가할 수 있따.&lt;/li&gt;&lt;/ol&gt;";

                    $scope.AddHtmlData = CONTENTS1;


                   


                    //alert(response.data.records);

                }, function (response) {


                    //return $q.reject(response.status + " " + response.data.error);

                    alert(response.status + " " + response.data.error);

                });





c문법,  C를 최신언어로 마이그 하면서 자주 보게되는 것 중 하나  strcmp/strncmp



c coding >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


/*

 * test.c

 *

 *  Created on: 2018. 11. 17.

 *      Author: DIFY

 */


#include <stdio.h>

#include <string.h>

#define _CRT_SECURE_NO_WARNINGS


int main()

{

int iresult = 0;

char sResult[30];

char * sSample1 = "ABCDA";

char * sSample2 = "ABCD";

char * sSample3 = "ABCDA";


char * iSample1 = "12345";

char * iSample2 = "1234";

char * iSample3 = "12345";


   /*char*************************************************************/

iresult = strcmp( sSample1, sSample2 );

sprintf(sResult, "%d", iresult);    // %d정수를 문자열로 set

printf("[sSample1:%s,sSample2:%s]=>결과값(sSample1>sSample2) : %s\n", sSample1, sSample2, sResult);


iresult = strcmp( sSample2, sSample1 );

sprintf(sResult, "%d", iresult);

printf("[sSample1:%s,sSample2:%s]=>결과값(sSample1<sSample2) : %s\n", sSample1, sSample2,sResult);


iresult = strcmp( sSample1, sSample3 );

sprintf(sResult, "%d", iresult);

printf("[sSample1:%s,sSample3:%s]=>결과값(sSample1=sSample3) : %s\n", sSample1, sSample3,sResult);


iresult = strncmp( sSample1, sSample2,4 );

sprintf(sResult, "%d", iresult);

printf("[sSample1:%s,sSample2:%s]=>결과값(sSample1,sSample2 4자리까지비교) : %s\n",sSample1, sSample2, sResult);


iresult = strncmp( sSample1, sSample2,5 );

sprintf(sResult, "%d", iresult);

printf("[sSample1:%s,sSample2:%s]=>결과값(sSample1,sSample2 5자리까지비교(ASCII 코드값)) : %s\n", sSample1, sSample2,sResult);



iresult = strncmp( sSample2, sSample1,5 );

sprintf(sResult, "%d", iresult);

printf("[sSample2:%s,sSample1:%s]=>결과값(sSample2,sSample1 5자리까지비교(ASCII 코드값)) : %s\n", sSample2, sSample1,sResult);



/*int*************************************************************/

iresult = strcmp( iSample1, iSample2 );

sprintf(sResult, "%d", iresult);

printf("[iSample1:%s,iSample2:%s]=>결과값(iSample1>iSample2) : %s\n", iSample1, iSample2, sResult);


iresult = strcmp( iSample2, iSample1 );

sprintf(sResult, "%d", iresult);

printf("[iSample1:%s,iSample2:%s]=>결과값(iSample1<iSample2) : %s\n", iSample1, iSample2,sResult);


iresult = strcmp( iSample1, iSample3 );

sprintf(sResult, "%d", iresult);

printf("[iSample1:%s,iSample3:%s]=>결과값(iSample1=iSample3) : %s\n", iSample1, iSample3,sResult);


iresult = strncmp( iSample1, iSample2,4 );

sprintf(sResult, "%d", iresult);

printf("[iSample1:%s,iSample2:%s]=>결과값(iSample1,iSample2 4자리까지비교) : %s\n",iSample1, iSample2, sResult);


iresult = strncmp( iSample1, iSample2,5 );

sprintf(sResult, "%d", iresult);

printf("[iSample1:%s,iSample2:%s]=>결과값(iSample1,iSample2 5자리까지비교(ASCII 코드값)) : %s\n", iSample1, iSample2,sResult);



iresult = strncmp( iSample2, iSample1,5 );

sprintf(sResult, "%d", iresult);

printf("[iSample2:%s,iSample1:%s]=>결과값(iSample2,iSample1 5자리까지비교(ASCII 코드값)) : %s\n", iSample2, iSample1,sResult);



return 0;


}


 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

console 결과값

[sSample1:ABCDA,sSample2:ABCD]=>결과값(sSample1>sSample2) : 1

[sSample1:ABCDA,sSample2:ABCD]=>결과값(sSample1<sSample2) : -1

[sSample1:ABCDA,sSample3:ABCDA]=>결과값(sSample1=sSample3) : 0

[sSample1:ABCDA,sSample2:ABCD]=>결과값(sSample1,sSample2 4자리까지비교) : 0

[sSample1:ABCDA,sSample2:ABCD]=>결과값(sSample1,sSample2 5자리까지비교(ASCII 코드값)) : 65

[sSample2:ABCD,sSample1:ABCDA]=>결과값(sSample2,sSample1 5자리까지비교(ASCII 코드값)) : -65

[iSample1:12345,iSample2:1234]=>결과값(iSample1>iSample2) : 1

[iSample1:12345,iSample2:1234]=>결과값(iSample1<iSample2) : -1

[iSample1:12345,iSample3:12345]=>결과값(iSample1=iSample3) : 0

[iSample1:12345,iSample2:1234]=>결과값(iSample1,iSample2 4자리까지비교) : 0

[iSample1:12345,iSample2:1234]=>결과값(iSample1,iSample2 5자리까지비교(ASCII 코드값)) : 53

[iSample2:1234,iSample1:12345]=>결과값(iSample2,iSample1 5자리까지비교(ASCII 코드값)) : -53




서식
문자
출력 형태
c 문자
d or i 부호 있는 십진법으로 나타난 정수
e 지수 표기법(Scientific notation) 으로 출력하되, e 문자를 이용한다.
E 지수 표기법(Scientific notation) 으로 출력하되, E 문자를 이용한다.
f 십진법으로 나타낸 부동 소수점 수
g %e나 %f 보다 간략하게 출력
G %E나 %f 보다 간략하게 출력
o 부호 있는 팔진수
s 문자열
u 부호없는 십진법으로 나타낸 정수
x 부호없는 16 진법으로 나타낸 정수 (소문자 사용)
X 부호없는 16 진법으로 나타낸 정수 (대문자 사용)
p 포인터 주소
n 아무것도 출력하지 않는다. 그 대신, 인자로 부호 있는 int 형을 가리키는 포인터를 전달해야 되는데, 여기에 현재까지 쓰여진 문자 수가 저장된다.
(참고, eclipse에서 c 사용하기, http://blog.moramcnt.com/?p=1272 )



C#에서 mariadb 사용하기

https://dev.mysql.com/downloads/connector/net/

Download Connector/NET(mysql-connector-net-8.0.13.msi)

mysql-connector-net-8.0.13.msi



 

C#프로젝트 [참조]에 라이브러리를 추가한다.(1개 : MySql.Data.dll)

C:\Program Files (x86)\MySQL\MySQL Connector Net 8.0.13\Assemblies\v4.5.2\MySql.Data.dll




<dbconnection class>에서 아래 라이브러리 이용하여 커넥션 클래스 구성.

오라클,msSql, mariadb 모두 비슷한 패턴임.

------------------------------------------------

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Data;

using MySql.Data.MySqlClient;


namespace testWebApplication1

{

    public class MariaDbAccess

    {


        #region 멤버변수


        private MySqlConnection oCnn = null;

        /// <summary>

        /// DB 연결 스트링

        /// </summary>

        private string _connectionString = "SERVER=서버;DATABASE=데이타베이스명;UID=아이디;PASSWORD=패스워드;";


------------------------------------------------


'프로그래밍 > c#' 카테고리의 다른 글

WebBrowser이용한 스크린스크래핑  (0) 2018.05.09
WebBrowser.DocumentText 한글깨짐  (0) 2018.05.07
using MySqlConnector  (0) 2018.05.07

Open Api 를 이용해서 Request & Response 된 데이타를 

테이블에 저장하도록 한다.

Schema구성


>kakao open api 분석

>스키마구성



>mysql table 스크립트

-- <table SCHEMA> START-----------------------

CREATE TABLE `requestdata` (
`SQSeq` bigint(20) NOT NULL AUTO_INCREMENT,
`SearchKind` varchar(20) NOT NULL DEFAULT 'WEB',
`Query` varchar(100) NOT NULL,
`SearchDate` date NOT NULL,
PRIMARY KEY (`SQSeq`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `responsedata` (
`SQSeq` bigint(20) NOT NULL,
`SubSeq` bigint(20) NOT NULL,
`Title` varchar(300) NOT NULL DEFAULT 'ETC',
`Contents` varchar(4000) DEFAULT NULL,
`Url` varchar(1000) DEFAULT NULL,
`Thumbnail_url` varchar(1000) DEFAULT NULL,
`Authors` varchar(1000) DEFAULT NULL,
`Price` int(11) DEFAULT NULL,
`Width` int(11) DEFAULT NULL,
`Height` int(11) DEFAULT NULL,
`Category` int(11) DEFAULT NULL,
`Datetime` date DEFAULT NULL,
`Etc` varchar(200) DEFAULT NULL,
PRIMARY KEY (`SQSeq`,`SubSeq`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- <table SCHEMA> END-----------------------



>스토어 프로시저로 등록/삭제

-- [START]요청 REQUESTDATA INSERT----------------

DELIMITER //

DROP PROCEDURE IF EXISTS SP_REQUESTDATA_INSERT //

CREATE PROCEDURE SP_REQUESTDATA_INSERT
(
IN InSearchKind varchar(20),
IN InQuery varchar(100),
OUT NewSQSeq bigint(20)
)

BEGIN
INSERT INTO requestdata
(
SearchKind
,Query
,SearchDate
)
VALUES
(
InSearchKind,
InQuery,
sysdate()
);

-- Auto Increment 값 조회
SELECT LAST_INSERT_ID()
INTO NewSQSeq; -- OUT 파라메터 담기

END//

DELIMITER ;
-- [END]요청 REQUESTDATA INSERT------------------


-- [START] 요청/결과 삭제 SP_REQUESTDATA_DELETE----
DELIMITER //

DROP PROCEDURE IF EXISTS SP_REQUESTDATA_DELETE //

CREATE PROCEDURE SP_REQUESTDATA_DELETE
(
IN InSQSeq bigint(20)
)

BEGIN

declare iResult bigint(20);
set iResult = 0;

DELETE FROM requestdata
WHERE SQSeq = InSQSeq;

DELETE FROM responsedata
WHERE SQSeq = InSQSeq;

END//

DELIMITER ;
-- [END]요청/결과 삭제 SP_REQUESTDATA_DELETE-------


-- [START]결과 SP_RESPONSEDATA_INSERT------------
DELIMITER //

DROP PROCEDURE IF EXISTS SP_RESPONSEDATA_INSERT //

CREATE PROCEDURE SP_RESPONSEDATA_INSERT
(
IN InSQSeq   bigint(20)
,IN InTitle   varchar(300)
,IN InContents    varchar(4000)
,IN InUrl varchar(1000)
,IN InThumbnail_url   varchar(1000)
,IN InAuthors varchar(1000)
,IN InPrice   int(11)
,IN InWidth   int(11)
,IN InHeight  int(11)
,IN InCategory    int(11)
,IN InDatetime    varchar(100)
,IN InEtc varchar(200)
,OUT OutResult bigint(20)
)

BEGIN

declare NewSubSeq bigint(20) default(0);

SELECT
IFNULL(MAX(SUBSEQ),0) + 1 into NewSubSeq
FROM RESPONSEDATA
WHERE SQSeq = InSQSeq;
SET OutResult = NewSubSeq;

INSERT INTO responsedata
(
SQSeq 
,SubSeq   
,Title    
,Contents 
,Url  
,Thumbnail_url    
,Authors  
,Price    
,Width    
,Height   
,Category 
,Datetime 
,Etc  
)
values
(
InSQSeq   
,NewSubSeq
,InTitle  
,InContents   
,InUrl    
,InThumbnail_url  
,InAuthors    
,InPrice  
,InWidth  
,InHeight 
,InCategory   
,date(InDatetime) 
,InEtc    
);


END//

DELIMITER ;
-- [END]결과 SP_RESPONSEDATA_INSERT--------------



>프로시저실행해서 등록하기


call SP_REQUESTDATA_INSERT('Book','삶의철학산책',@NewSQSeq);
select @NewSQSeq;

call SP_RESPONSEDATA_INSERT(1,'드 보통의 삶의 철학산책','복잡하고 힘겨운 삶을 유쾌하게 만드는 삶의 거장들이 알려주는 행복의 철학. 인기없음, 가난, 좌절, 부당함, 실연, 고통에 대한 허브 치료와도 같은 유쾌한 위안을 한권의 책으로 엮었다.','http://book.daum.net/detail/book.do?bookid=KOR9788984980624','http://t1.daumcdn.net/thumb/R72x100/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fbook%2FKOR9788984980624%3Fmoddttm=20160223080929','알랭 드 보통',17000,0,0,5,'2002-04-25T00:00:00.000+09:00','8984980625 9788984980624',@OutResult);

select @OutResult;

call SP_RESPONSEDATA_INSERT(1,'고대 로마+한강역사문화탐사+삶의철학산책','&#39;고대 문명 시리즈&#39; 두 번째 권으로 고대 로마를 찾아간다. 로마의 사회, 정치, 문화, 예술의 다양한 면모를 가능한 명료하고 직접적으로 기술하여 로마를 직접 체험하는 느낌을 가질 수...','http://book.daum.net/detail/book.do?bookid=BOK00000039062LI','http://t1.daumcdn.net/thumb/P72x100/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fbook%2FBOK00000039062LI%3Fmoddttm=20150609170927','안나 마리아 리베라티',95000,0,0,0,'2003-07-20T00:00:00.000+09:00','0004953282 0100004953286',@OutResult);

response된data.txt




'프로그래밍 > PHP' 카테고리의 다른 글

kanboard로 프로젝트 관리하기  (0) 2020.05.26
WAMP 설치  (0) 2020.05.26
curl kakao open api 도서검색  (0) 2018.08.10
curl kakao open api 이미지검색하기  (0) 2018.08.06
curl kakao open api사용하기  (0) 2018.08.05

다움API 3번째 도서검색.

이미지,블로그,웹,도서,푸시알림까지 되면  

실제 필요한 물건을 만들수 있지 않을까..... 생각아 좀더 나거라~


오픈API 사용량에 관계없이 무제한으로 쓸수있는지 궁금해지네.... 

스크래핑 하지 않고 이렇게 API호출해서 받으니 쉽고 빠르고 좋다.


testpage 도서검색) http://doitforyou.co.kr/test/curl_daum_search_book.php

testpage 웹검색) http://doitforyou.co.kr/test/curl_daum_search_web.php

testpage 이미지검색) http://doitforyou.co.kr/test/curl_daum_search_image.php


<?php
function request($path, $query, $content_type = 'json')
{
$api_server = 'https://dapi.kakao.com';
$headers = array('Authorization: KakaoAK {APIKEY} ');
$opts = array(
CURLOPT_URL => $api_server . $path . '.' . $content_type . '?' . $query,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSLVERSION => 1,
CURLOPT_HEADER => false,
CURLOPT_HTTPHEADER => $headers
);

$curl_session = curl_init();
curl_setopt_array($curl_session, $opts);
$return_data = curl_exec($curl_session);

if (curl_errno($curl_session)) {
throw new Exception(curl_error($curl_session));
} else {
//print_r(curl_getinfo($curl_session));
curl_close($curl_session);
return $return_data;
}
}


$path = '/v2/search/book';
$content_type = 'json'; // json or xml
$params = http_build_query(array(
'page' => 1,
'size' => 50,
'query' => 'PHP'
,
'category' => 33
));

$res = request($path, $params, $content_type);

//header('Content-Type: application/' . $content_type . '; charset=utf-8');
// echo $res;
//echo $res;
//var_dump($res);
$dt = json_decode($res); //json data type => php object로 변환
//json_encode : php object/array => json data type으로 변환
// var_dump( $dt);

$tCount = $dt->meta->total_count;
$iCnt = count($dt->documents);
echo "<br>";
echo "tCnt_totalcnt:".$tCount . "/" ."iCnt_documents:".$iCnt;
echo "<br>";

for ($i=0; $i < $iCnt; $i++)
{
echo "<p>";

echo "title:".$dt->documents[$i]->title."<br>";
echo "contents:".$dt->documents[$i]->contents."<br>";
echo "url:".$dt->documents[$i]->url."<br>";
echo "isbn:".$dt->documents[$i]->isbn."<br>";

$iCntAuthor = 0;
$iCntAuthor = count($dt->documents[$i]->authors);

for($z=0; $z < $iCntAuthor; $z++)
{
if($z==0){
echo "authors:";
}
echo $dt->documents[$i]->authors[$z];
if($z <> ($iCntAuthor-1) )
{
echo ",";
};
}

echo "</p>";

}
?>


'프로그래밍 > PHP' 카테고리의 다른 글

WAMP 설치  (0) 2020.05.26
Open Api Request / Response Schema구성&실행  (0) 2018.08.19
curl kakao open api 이미지검색하기  (0) 2018.08.06
curl kakao open api사용하기  (0) 2018.08.05
php CURL 사용하기  (0) 2018.07.31

+ Recent posts