AdMob集成插页式广告指南教程Word文件下载.docx
- 文档编号:22274900
- 上传时间:2023-02-03
- 格式:DOCX
- 页数:35
- 大小:24.78KB
AdMob集成插页式广告指南教程Word文件下载.docx
《AdMob集成插页式广告指南教程Word文件下载.docx》由会员分享,可在线阅读,更多相关《AdMob集成插页式广告指南教程Word文件下载.docx(35页珍藏版)》请在冰豆网上搜索。
HANDLEhThread1=NULL;
HANDLEhThread2=NULL;
HANDLEhOut;
hOut=GetStdHandle(STD_OUTPUT_HANDLE);
WORDatt=FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_INTENSITY|BACKGROUND_BLUE;
SetConsoleTextAttribute(hOut,att);
SMALL_RECTrc={0,0,80,25};
SetConsoleWindowInfo(hOut,true,&
rc);
SetConsoleTitle(L"
TheChatTools"
ClearScreen();
InitializeCriticalSection(&
gcc);
hThread2=CreateThread(NULL,NULL,sendCustmer,NULL,NULL,NULL);
hThread1=CreateThread(NULL,NULL,displayServer,NULL,NULL,NULL);
HANDLEtHandle[]={hThread1,hThread2};
WaitForMultipleObjects(2,tHandle,true,INFINITE);
DeleteCriticalSection(&
WSACleanup();
CloseHandle(hThread1);
CloseHandle(hThread2);
}
DWORDWINAPIsendCustmer(LPVOIDlpParameter)
WSADATAwsaData;
WSAStartup(MAKEWORD(2,2),&
wsaData);
//向服务器发起请求
sockaddr_insockAddr;
memset(&
sockAddr,0,sizeof(sockAddr));
//每个字节都用0填充
sockAddr.sin_family=PF_INET;
sockAddr.sin_addr.s_addr=inet_addr("
192.168.109.23"
//sockAddr.sin_addr.s_addr=htonl(INADDR_ANY);
sockAddr.sin_port=htons(1234);
charSendBuffer[MAXBYTE];
while
(1)
{
SOCKETsock;
do
sock=socket(PF_INET,SOCK_STREAM,IPPROTO_TCP);
if(0!
=connect(sock,(SOCKADDR*)&
sockAddr,sizeof(SOCKADDR)))
Sleep
(1);
}
else
break;
}while(true);
memset(SendBuffer,0,MAXBYTE);
gotoxy(0,21);
ClearScreen1();
#if0
for(intj=0;
j<
100;
++j)
printf_s("
"
#endif
gets_s(SendBuffer);
}while(0==strlen(SendBuffer));
gotoxy(0,g_postion);
if(g_postion<
20)
[代码][GoogleGo]代码
packagemain
import(
io/ioutil"
net/http"
net/"
fmt"
encoding/json"
)
//----------------------------------
//黄金数据调用示例代码-聚合数据
//在线接口文档:
www/docs/29
constAPPKEY="
*******************"
//您申请的APPKEY
funcmain(){
//1.上海黄金交易所
Request1()
//2.上海期货交易所
Request2()
//3.银行账户黄金
Request3()
}
//1.上海黄金交易所
funcRequest1(){
//请求地址
juhe:
="
web:
8080/finance/gold/shgold"
//初始化参数
param:
=.Values{}
//配置请求参数,方法内部已处理encode问题,中文参数可以直接传参
param.Set("
key"
APPKEY)//APPKey
v"
"
)//JSON格式版本(0或1)默认为0
//发送请求
data,err:
=Get(juhe,param)
iferr!
=nil{
fmt.Errorf("
请求失败,错误信息:
\r\n%v"
err)
}else{
varnetReturnmap[string]interface{}
json.Unmarshal(data,&
netReturn)
ifnetReturn["
error_code"
].(float64)==0{
fmt.Printf("
接口返回result字段是:
netReturn["
result"
])
//2.上海期货交易所
funcRequest2(){
8080/finance/gold/shfuture"
//3.银行账户黄金
funcRequest3(){
8080/finance/gold/bankgold"
//get网络请求
funcGet(apistring,params.Values)(rs[]byte,errerror){
var*.
err=.Parse(api)
解析错误:
returnnil,err
//如果参数中有中文参数,这个方法会进行Encode
.RawQuery=params.Encode()
resp,err:
=http.Get(.String())
fmt.Println("
err:
deferresp.Body.Close()
returnioutil.ReadAll(resp.Body)
//post网络请求,params是.Values类型
funcPost(apistring,params.Values)(rs[]byte,errerror){
=http.PostForm(api,params)
returnnil,err
deferresp.Body.Close()
代码描述:
基于GO的黄金数据接口调用代码实例
关联数据:
黄金数据
[代码][C#]代码
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Net;
usingSystem.IO;
usingXfrog.Net;
usingSystem.Diagnostics;
usingSystem.Web;
//代码中JsonObject类下载地址:
/download/gcm3206021155665/7458439
namespaceConsoleAPI
classProgram
{
staticvoidMain(string[]args)
stringappkey="
;
//配置您申请的appkey
string1="
varparameters1=newDictionary<
string,string>
();
parameters1.Add("
appkey);
//你申请的key
"
//JSON格式版本(0或1)默认为0
stringresult1=sendPost(1,parameters1,"
get"
JsonObjectnewObj1=newJsonObject(result1);
StringerrorCode1=newObj1["
].Value;
if(errorCode1=="
0"
)
Debug.WriteLine("
成功"
Debug.WriteLine(newObj1);
//Debug.WriteLine("
失败"
Debug.WriteLine(newObj1["
].Value+"
:
+newObj1["
reason"
].Value);
string2="
varparameters2=newDictionary<
parameters2.Add("
stringresult2=sendPost(2,parameters2,"
JsonObjectnewObj2=newJsonObject(result2);
StringerrorCode2=newObj2["
if(errorCode2=="
Debug.WriteLine(newObj2);
Debug.WriteLine(newObj2["
+newObj2["
string3="
varparameters3=newDictionary<
parameters3.Add("
stringresult3=sendPost(3,parameters3,"
JsonObjectnewObj3=newJsonObject(result3);
StringerrorCode3=newObj3["
if(errorCode3=="
Debug.WriteLine(newObj3);
Debug.WriteLine(newObj3["
+newObj3["
///<
summary>
///Http(GET/POST)
/summary>
paramname="
>
请求<
/param>
parameters"
请求参数<
method"
请求方法<
returns>
响应内容<
/returns>
staticstringsendPost(string,IDictionary<
parameters,stringmethod)
if(method.ToLower()=="
post"
HttpWebRequestreq=null;
HttpWebResponsersp=null;
System.IO.StreamreqStream=null;
try
req=(HttpWebRequest)WebRequest.Create();
req.Method=method;
req.KeepAlive=false;
req.ProtocolVersion=HttpVersion.Version10;
req.Timeout=5000;
req.ContentType="
application/x-www-form-encoded;
charset=utf-8"
byte[]postData=Encoding.UTF8.GetBytes(BuildQuery(parameters,"
utf8"
));
reqStream=req.GetRequestStream();
reqStream.Write(postData,0,postData.Length);
rsp=(HttpWebResponse)req.GetResponse();
Encodingencoding=Encoding.GetEncoding(rsp.CharacterSet);
returnGetResponseAsString(rsp,encoding);
catch(Exceptionex)
returnex.Message;
finally
if(reqStream!
=null)reqStream.Close();
if(rsp!
=null)rsp.Close();
//创建请求
HttpWebRequestrequest=(HttpWebRequest)WebRequest.Create(+"
?
+BuildQuery(parameters,"
//GET请求
request.Method="
GET"
request.ReadWriteTimeout=5000;
request.ContentType="
text/html;
charset=UTF-8"
HttpWebResponseresponse=(HttpWebResponse)request.GetResponse();
StreammyResponseStream=response.GetResponseStream();
StreamReadermyStreamReader=newStreamReader(myResponseStream,Encoding.GetEncoding("
utf-8"
//返回内容
stringretString=myStreamReader.ReadToEnd();
returnretString;
///组装普通文本请求参数。
Key-Value形式请求参数字典<
编码后的请求数据<
staticstringBuildQuery(IDictionary<
parameters,stringencode)
StringBuilderpostData=newStringBuilder();
boolhasParam=false;
IEnumerator<
KeyValuePair<
dem=parameters.GetEnumerator();
while(dem.MoveNext())
stringname=dem.Current.Key;
stringvalue=dem.Current.Value;
//忽略参数名或参数值为空的参数
if(!
string.IsNullOrEmpty(name))//&
&
!
string.IsNullOrEmpty(value)
if(hasParam)
postData.Append("
postData.Append(name);
if(encode=="
gb2312"
postData.Append(HttpUtility.Encode(value,Encoding.GetEncoding("
)));
elseif(encode=="
postData.Append(HttpUtility.Encode(value,Encoding.UTF8));
postData.Append(value);
hasParam=true;
returnpostData.ToString();
///把响应流转换为文本。
rsp"
响应流对象<
encoding"
编码方式<
响应文本<
staticstringGetResponseAsString(HttpWebResponsersp,Encodingencoding)
System.IO.Streamstream=null;
StreamReaderreader=null;
//以字符流的方式读
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- AdMob 集成 插页 广告 指南 教程
![提示](https://static.bdocx.com/images/bang_tan.gif)