mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 11:06:50 +01:00
added TwitterClient sample
This commit is contained in:
@@ -9,4 +9,5 @@ add_subdirectory(TimeServer)
|
|||||||
add_subdirectory(dict)
|
add_subdirectory(dict)
|
||||||
add_subdirectory(download)
|
add_subdirectory(download)
|
||||||
add_subdirectory(httpget)
|
add_subdirectory(httpget)
|
||||||
|
add_subdirectory(TwitterClient)
|
||||||
|
|
||||||
|
|||||||
@@ -19,3 +19,4 @@ projects:
|
|||||||
$(MAKE) -C EchoServer $(MAKECMDGOALS)
|
$(MAKE) -C EchoServer $(MAKECMDGOALS)
|
||||||
$(MAKE) -C Mail $(MAKECMDGOALS)
|
$(MAKE) -C Mail $(MAKECMDGOALS)
|
||||||
$(MAKE) -C Ping $(MAKECMDGOALS)
|
$(MAKE) -C Ping $(MAKECMDGOALS)
|
||||||
|
$(MAKE) -C TwitterClient $(MAKECMDGOALS)
|
||||||
|
|||||||
8
Net/samples/TwitterClient/CMakeLists.txt
Normal file
8
Net/samples/TwitterClient/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
set(SAMPLE_NAME "TwitterClient")
|
||||||
|
|
||||||
|
set(LOCAL_SRCS "")
|
||||||
|
aux_source_directory(src LOCAL_SRCS)
|
||||||
|
|
||||||
|
add_executable( ${SAMPLE_NAME} ${LOCAL_SRCS} )
|
||||||
|
set_target_properties( ${SAMPLE_NAME} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
|
||||||
|
target_link_libraries( ${SAMPLE_NAME} PocoNet PocoUtil PocoXML PocoFoundation )
|
||||||
17
Net/samples/TwitterClient/Makefile
Normal file
17
Net/samples/TwitterClient/Makefile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#
|
||||||
|
# Makefile
|
||||||
|
#
|
||||||
|
# $Id: //poco/Main/Net/samples/TwitterClient/Makefile#1 $
|
||||||
|
#
|
||||||
|
# Makefile for Poco Twitter Client
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(POCO_BASE)/build/rules/global
|
||||||
|
|
||||||
|
objects = Twitter TweetApp
|
||||||
|
|
||||||
|
target = tweet
|
||||||
|
target_version = 1
|
||||||
|
target_libs = PocoUtil PocoNet PocoXML PocoFoundation
|
||||||
|
|
||||||
|
include $(POCO_BASE)/build/rules/exec
|
||||||
245
Net/samples/TwitterClient/TwitterClient_vs71.vcproj
Normal file
245
Net/samples/TwitterClient/TwitterClient_vs71.vcproj
Normal file
@@ -0,0 +1,245 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="7.10"
|
||||||
|
Name="TwitterClient"
|
||||||
|
ProjectGUID="{D4483069-8403-4013-822D-100D349ABCA7}"
|
||||||
|
Keyword="Win32Proj">
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"/>
|
||||||
|
</Platforms>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="debug_shared|Win32"
|
||||||
|
OutputDirectory="obj\debug_shared"
|
||||||
|
IntermediateDirectory="obj\debug_shared"
|
||||||
|
ConfigurationType="1"
|
||||||
|
UseOfMFC="2"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include"
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
|
||||||
|
MinimalRebuild="TRUE"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
BufferSecurityCheck="TRUE"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
|
RuntimeTypeInfo="TRUE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="4"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoNetd.lib PocoUtild.lib"
|
||||||
|
OutputFile="bin/tweetd.exe"
|
||||||
|
LinkIncremental="2"
|
||||||
|
AdditionalLibraryDirectories="..\..\..\lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
ProgramDatabaseFile="bin/TwitterClientd.pdb"
|
||||||
|
SubSystem="1"
|
||||||
|
TargetMachine="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="release_shared|Win32"
|
||||||
|
OutputDirectory="obj\release_shared"
|
||||||
|
IntermediateDirectory="obj\release_shared"
|
||||||
|
ConfigurationType="1"
|
||||||
|
UseOfMFC="2"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="4"
|
||||||
|
InlineFunctionExpansion="1"
|
||||||
|
EnableIntrinsicFunctions="TRUE"
|
||||||
|
FavorSizeOrSpeed="1"
|
||||||
|
OmitFramePointers="TRUE"
|
||||||
|
OptimizeForWindowsApplication="TRUE"
|
||||||
|
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include"
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
|
||||||
|
StringPooling="TRUE"
|
||||||
|
RuntimeLibrary="2"
|
||||||
|
BufferSecurityCheck="FALSE"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
|
RuntimeTypeInfo="TRUE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="3"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoNet.lib PocoUtil.lib"
|
||||||
|
OutputFile="bin/tweet.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="..\..\..\lib"
|
||||||
|
GenerateDebugInformation="FALSE"
|
||||||
|
ProgramDatabaseFile=""
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="debug_static|Win32"
|
||||||
|
OutputDirectory="obj\debug_static"
|
||||||
|
IntermediateDirectory="obj\debug_static"
|
||||||
|
ConfigurationType="1">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include"
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
|
||||||
|
MinimalRebuild="TRUE"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
BufferSecurityCheck="TRUE"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
|
RuntimeTypeInfo="TRUE"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="4"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="PocoFoundationmtd.lib PocoXMLmtd.lib PocoNetmtd.lib PocoUtilmtd.lib ws2_32.lib"
|
||||||
|
AdditionalLibraryDirectories="..\..\..\lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
ProgramDatabaseFile="bin/TwitterClientmtd.pdb"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="release_static|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="1">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include"
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_STATIC;WINVER=0x0500"
|
||||||
|
StringPooling="TRUE"
|
||||||
|
RuntimeLibrary="2"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="TRUE"
|
||||||
|
RuntimeTypeInfo="TRUE"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="PocoFoundationmt.lib PocoXMLmt.lib PocoNetmt.lib PocoUtilmt.lib ws2_32.lib"
|
||||||
|
AdditionalLibraryDirectories="..\..\..\lib"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="">
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\TweetApp.cpp">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Twitter.cpp">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
Filter="">
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Twitter.h">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
||||||
221
Net/samples/TwitterClient/TwitterClient_vs80.vcproj
Normal file
221
Net/samples/TwitterClient/TwitterClient_vs80.vcproj
Normal file
@@ -0,0 +1,221 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="8.00"
|
||||||
|
Name="TwitterClient"
|
||||||
|
ProjectGUID="{D4483069-8403-4013-822D-100D349ABCA7}"
|
||||||
|
Keyword="Win32Proj"
|
||||||
|
>
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"
|
||||||
|
/>
|
||||||
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="debug_shared|Win32"
|
||||||
|
OutputDirectory="obj\debug_shared"
|
||||||
|
IntermediateDirectory="obj\debug_shared"
|
||||||
|
ConfigurationType="1"
|
||||||
|
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||||
|
UseOfMFC="2"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include"
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
|
||||||
|
MinimalRebuild="true"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
BufferSecurityCheck="true"
|
||||||
|
TreatWChar_tAsBuiltInType="true"
|
||||||
|
ForceConformanceInForLoopScope="true"
|
||||||
|
RuntimeTypeInfo="true"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoNetd.lib PocoUtild.lib"
|
||||||
|
OutputFile="bin/tweetd.exe"
|
||||||
|
LinkIncremental="2"
|
||||||
|
AdditionalLibraryDirectories="..\..\..\lib"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
ProgramDatabaseFile="bin/TwitterClientd.pdb"
|
||||||
|
SubSystem="1"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="release_shared|Win32"
|
||||||
|
OutputDirectory="obj\release_shared"
|
||||||
|
IntermediateDirectory="obj\release_shared"
|
||||||
|
ConfigurationType="1"
|
||||||
|
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||||
|
UseOfMFC="2"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="4"
|
||||||
|
InlineFunctionExpansion="1"
|
||||||
|
EnableIntrinsicFunctions="true"
|
||||||
|
FavorSizeOrSpeed="1"
|
||||||
|
OmitFramePointers="true"
|
||||||
|
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include"
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
|
||||||
|
StringPooling="true"
|
||||||
|
RuntimeLibrary="2"
|
||||||
|
BufferSecurityCheck="false"
|
||||||
|
TreatWChar_tAsBuiltInType="true"
|
||||||
|
ForceConformanceInForLoopScope="true"
|
||||||
|
RuntimeTypeInfo="true"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoNet.lib PocoUtil.lib"
|
||||||
|
OutputFile="bin/tweet.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="..\..\..\lib"
|
||||||
|
GenerateDebugInformation="false"
|
||||||
|
ProgramDatabaseFile=""
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\TweetApp.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Twitter.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Twitter.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
||||||
216
Net/samples/TwitterClient/TwitterClient_vs90.vcproj
Normal file
216
Net/samples/TwitterClient/TwitterClient_vs90.vcproj
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.00"
|
||||||
|
Name="TwitterClient"
|
||||||
|
ProjectGUID="{D4483069-8403-4013-822D-100D349ABCA7}"
|
||||||
|
Keyword="Win32Proj"
|
||||||
|
TargetFrameworkVersion="0"
|
||||||
|
>
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"
|
||||||
|
/>
|
||||||
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="debug_shared|Win32"
|
||||||
|
OutputDirectory="obj\debug_shared"
|
||||||
|
IntermediateDirectory="obj\debug_shared"
|
||||||
|
ConfigurationType="1"
|
||||||
|
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||||
|
UseOfMFC="2"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include"
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
|
||||||
|
MinimalRebuild="true"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
BufferSecurityCheck="true"
|
||||||
|
TreatWChar_tAsBuiltInType="true"
|
||||||
|
ForceConformanceInForLoopScope="true"
|
||||||
|
RuntimeTypeInfo="true"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="false"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoNetd.lib PocoUtild.lib"
|
||||||
|
OutputFile="bin/tweetd.exe"
|
||||||
|
LinkIncremental="2"
|
||||||
|
AdditionalLibraryDirectories="..\..\..\lib"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
ProgramDatabaseFile="bin/TwitterClientd.pdb"
|
||||||
|
SubSystem="1"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="release_shared|Win32"
|
||||||
|
OutputDirectory="obj\release_shared"
|
||||||
|
IntermediateDirectory="obj\release_shared"
|
||||||
|
ConfigurationType="1"
|
||||||
|
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||||
|
UseOfMFC="2"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="4"
|
||||||
|
InlineFunctionExpansion="1"
|
||||||
|
EnableIntrinsicFunctions="true"
|
||||||
|
FavorSizeOrSpeed="1"
|
||||||
|
OmitFramePointers="true"
|
||||||
|
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include"
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
|
||||||
|
StringPooling="true"
|
||||||
|
RuntimeLibrary="2"
|
||||||
|
BufferSecurityCheck="false"
|
||||||
|
TreatWChar_tAsBuiltInType="true"
|
||||||
|
ForceConformanceInForLoopScope="true"
|
||||||
|
RuntimeTypeInfo="true"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="false"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoNet.lib PocoUtil.lib"
|
||||||
|
OutputFile="bin/tweet.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="..\..\..\lib"
|
||||||
|
GenerateDebugInformation="false"
|
||||||
|
ProgramDatabaseFile=""
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\TweetApp.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Twitter.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Twitter.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
||||||
146
Net/samples/TwitterClient/src/TweetApp.cpp
Normal file
146
Net/samples/TwitterClient/src/TweetApp.cpp
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
//
|
||||||
|
// TwitterApp.cpp
|
||||||
|
//
|
||||||
|
// $Id: //poco/Main/Net/samples/TwitterClient/src/TweetApp.cpp#1 $
|
||||||
|
//
|
||||||
|
// A very simple command-line Twitter client.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2009, Applied Informatics Software Engineering GmbH.
|
||||||
|
// and Contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
// obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
// this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
// execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
// Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
// do so, all subject to the following:
|
||||||
|
//
|
||||||
|
// The copyright notices in the Software and this entire statement, including
|
||||||
|
// the above license grant, this restriction and the following disclaimer,
|
||||||
|
// must be included in all copies of the Software, in whole or in part, and
|
||||||
|
// all derivative works of the Software, unless such copies or derivative
|
||||||
|
// works are solely in the form of machine-executable object code generated by
|
||||||
|
// a source language processor.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#include "Poco/Util/Application.h"
|
||||||
|
#include "Poco/Util/Option.h"
|
||||||
|
#include "Poco/Util/OptionSet.h"
|
||||||
|
#include "Poco/Util/HelpFormatter.h"
|
||||||
|
#include "Twitter.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
using Poco::Util::Application;
|
||||||
|
using Poco::Util::Option;
|
||||||
|
using Poco::Util::OptionSet;
|
||||||
|
using Poco::Util::HelpFormatter;
|
||||||
|
using Poco::Util::AbstractConfiguration;
|
||||||
|
using Poco::Util::OptionCallback;
|
||||||
|
|
||||||
|
|
||||||
|
class TweetApp: public Application
|
||||||
|
/// A very simple Twitter command-line client.
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TweetApp():
|
||||||
|
_status(Application::EXIT_OK)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void defineOptions(OptionSet& options)
|
||||||
|
{
|
||||||
|
Application::defineOptions(options);
|
||||||
|
|
||||||
|
options.addOption(
|
||||||
|
Option("help", "h", "display help information on command line arguments")
|
||||||
|
.required(false)
|
||||||
|
.repeatable(false)
|
||||||
|
.callback(OptionCallback<TweetApp>(this, &TweetApp::handleHelp)));
|
||||||
|
|
||||||
|
options.addOption(
|
||||||
|
Option("username", "u", "specify the Twitter user/account name")
|
||||||
|
.required(true)
|
||||||
|
.repeatable(false)
|
||||||
|
.argument("account")
|
||||||
|
.callback(OptionCallback<TweetApp>(this, &TweetApp::handleUsername)));
|
||||||
|
|
||||||
|
options.addOption(
|
||||||
|
Option("password", "p", "specify the Twitter password")
|
||||||
|
.required(true)
|
||||||
|
.repeatable(false)
|
||||||
|
.argument("password")
|
||||||
|
.callback(OptionCallback<TweetApp>(this, &TweetApp::handlePassword)));
|
||||||
|
|
||||||
|
options.addOption(
|
||||||
|
Option("message", "m", "specify the status message")
|
||||||
|
.required(false)
|
||||||
|
.repeatable(true)
|
||||||
|
.argument("message")
|
||||||
|
.callback(OptionCallback<TweetApp>(this, &TweetApp::handleMessage)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleHelp(const std::string& name, const std::string& value)
|
||||||
|
{
|
||||||
|
displayHelp();
|
||||||
|
stopOptionsProcessing();
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleUsername(const std::string& name, const std::string& value)
|
||||||
|
{
|
||||||
|
_username = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void handlePassword(const std::string& name, const std::string& value)
|
||||||
|
{
|
||||||
|
_password = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleMessage(const std::string& name, const std::string& value)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_twitter.login(_username, _password);
|
||||||
|
Poco::Int64 statusId = _twitter.update(value);
|
||||||
|
std::cout << statusId << std::endl;
|
||||||
|
}
|
||||||
|
catch (Poco::Exception& exc)
|
||||||
|
{
|
||||||
|
std::cerr << exc.displayText() << std::endl;
|
||||||
|
_status = Application::EXIT_SOFTWARE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void displayHelp()
|
||||||
|
{
|
||||||
|
HelpFormatter helpFormatter(options());
|
||||||
|
helpFormatter.setCommand(commandName());
|
||||||
|
helpFormatter.setUsage("OPTIONS");
|
||||||
|
helpFormatter.setHeader("A simple Twitter command line client for posting status updates.");
|
||||||
|
helpFormatter.format(std::cout);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(const std::vector<std::string>& args)
|
||||||
|
{
|
||||||
|
return _status;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string _username;
|
||||||
|
std::string _password;
|
||||||
|
Twitter _twitter;
|
||||||
|
int _status;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
POCO_APP_MAIN(TweetApp)
|
||||||
135
Net/samples/TwitterClient/src/Twitter.cpp
Normal file
135
Net/samples/TwitterClient/src/Twitter.cpp
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
//
|
||||||
|
// Twitter.cpp
|
||||||
|
//
|
||||||
|
// $Id: //poco/Main/Net/samples/TwitterClient/src/Twitter.cpp#1 $
|
||||||
|
//
|
||||||
|
// A C++ implementation of a Twitter client based on the POCO Net library.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2009, Applied Informatics Software Engineering GmbH.
|
||||||
|
// and Contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
// obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
// this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
// execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
// Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
// do so, all subject to the following:
|
||||||
|
//
|
||||||
|
// The copyright notices in the Software and this entire statement, including
|
||||||
|
// the above license grant, this restriction and the following disclaimer,
|
||||||
|
// must be included in all copies of the Software, in whole or in part, and
|
||||||
|
// all derivative works of the Software, unless such copies or derivative
|
||||||
|
// works are solely in the form of machine-executable object code generated by
|
||||||
|
// a source language processor.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#include "Twitter.h"
|
||||||
|
#include "Poco/Net/HTTPClientSession.h"
|
||||||
|
#include "Poco/Net/HTTPRequest.h"
|
||||||
|
#include "Poco/Net/HTTPResponse.h"
|
||||||
|
#include "Poco/Net/HTTPBasicCredentials.h"
|
||||||
|
#include "Poco/DOM/DOMParser.h"
|
||||||
|
#include "Poco/DOM/NodeList.h"
|
||||||
|
#include "Poco/SAX/InputSource.h"
|
||||||
|
#include "Poco/URI.h"
|
||||||
|
#include "Poco/NumberParser.h"
|
||||||
|
|
||||||
|
|
||||||
|
const std::string Twitter::TWITTER_URI("http://twitter.com/statuses/");
|
||||||
|
|
||||||
|
|
||||||
|
Twitter::Twitter():
|
||||||
|
_uri(TWITTER_URI)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Twitter::Twitter(const std::string& twitterURI):
|
||||||
|
_uri(twitterURI)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Twitter::~Twitter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Twitter::login(const std::string& username, const std::string& password)
|
||||||
|
{
|
||||||
|
_username = username;
|
||||||
|
_password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Poco::Int64 Twitter::update(const std::string& status)
|
||||||
|
{
|
||||||
|
Poco::Net::HTMLForm form;
|
||||||
|
form.set("status", status);
|
||||||
|
Poco::AutoPtr<Poco::XML::Document> pResult = invoke(Poco::Net::HTTPRequest::HTTP_POST, "update", form);
|
||||||
|
Poco::AutoPtr<Poco::XML::NodeList> pList = pResult->getElementsByTagName("id");
|
||||||
|
if (pList->length() > 0)
|
||||||
|
{
|
||||||
|
return Poco::NumberParser::parse64(pList->item(0)->innerText());
|
||||||
|
}
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Poco::AutoPtr<Poco::XML::Document> Twitter::invoke(const std::string& httpMethod, const std::string& twitterMethod, Poco::Net::HTMLForm& form)
|
||||||
|
{
|
||||||
|
// Create the request URI.
|
||||||
|
// We use the XML version of the Twitter API.
|
||||||
|
Poco::URI uri(_uri + twitterMethod + ".xml");
|
||||||
|
std::string path(uri.getPath());
|
||||||
|
|
||||||
|
Poco::Net::HTTPClientSession session(uri.getHost(), uri.getPort());
|
||||||
|
Poco::Net::HTTPRequest req(httpMethod, path, Poco::Net::HTTPMessage::HTTP_1_1);
|
||||||
|
|
||||||
|
// Add username and password (HTTP basic authentication) to the request.
|
||||||
|
Poco::Net::HTTPBasicCredentials cred(_username, _password);
|
||||||
|
cred.authenticate(req);
|
||||||
|
|
||||||
|
// Send the request.
|
||||||
|
form.prepareSubmit(req);
|
||||||
|
std::ostream& ostr = session.sendRequest(req);
|
||||||
|
form.write(ostr);
|
||||||
|
|
||||||
|
// Receive the response.
|
||||||
|
Poco::Net::HTTPResponse res;
|
||||||
|
std::istream& rs = session.receiveResponse(res);
|
||||||
|
|
||||||
|
// Create a DOM document from the response.
|
||||||
|
Poco::XML::DOMParser parser;
|
||||||
|
parser.setFeature(Poco::XML::DOMParser::FEATURE_WHITESPACE, true);
|
||||||
|
parser.setFeature(Poco::XML::XMLReader::FEATURE_NAMESPACES, false);
|
||||||
|
Poco::XML::InputSource source(rs);
|
||||||
|
Poco::AutoPtr<Poco::XML::Document> pDoc = parser.parse(&source);
|
||||||
|
|
||||||
|
// If everything went fine, return the XML document.
|
||||||
|
// Otherwise look for an error message in the XML document.
|
||||||
|
if (res.getStatus() == Poco::Net::HTTPResponse::HTTP_OK)
|
||||||
|
{
|
||||||
|
return pDoc;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string error(res.getReason());
|
||||||
|
Poco::AutoPtr<Poco::XML::NodeList> pList = pDoc->getElementsByTagName("error");
|
||||||
|
if (pList->length() > 0)
|
||||||
|
{
|
||||||
|
error += ": ";
|
||||||
|
error += pList->item(0)->innerText();
|
||||||
|
}
|
||||||
|
throw Poco::ApplicationException("Twitter Error", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
92
Net/samples/TwitterClient/src/Twitter.h
Normal file
92
Net/samples/TwitterClient/src/Twitter.h
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
//
|
||||||
|
// Twitter.h
|
||||||
|
//
|
||||||
|
// $Id: //poco/Main/Net/samples/TwitterClient/src/Twitter.h#1 $
|
||||||
|
//
|
||||||
|
// A C++ implementation of a Twitter client based on the POCO Net library.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2009, Applied Informatics Software Engineering GmbH.
|
||||||
|
// and Contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
// obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
// this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
// execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
// Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
// do so, all subject to the following:
|
||||||
|
//
|
||||||
|
// The copyright notices in the Software and this entire statement, including
|
||||||
|
// the above license grant, this restriction and the following disclaimer,
|
||||||
|
// must be included in all copies of the Software, in whole or in part, and
|
||||||
|
// all derivative works of the Software, unless such copies or derivative
|
||||||
|
// works are solely in the form of machine-executable object code generated by
|
||||||
|
// a source language processor.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef Twitter_INCLUDED
|
||||||
|
#define Twitter_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
|
#include "Poco/Poco.h"
|
||||||
|
#include "Poco/Net/HTMLForm.h"
|
||||||
|
#include "Poco/DOM/Document.h"
|
||||||
|
#include "Poco/AutoPtr.h"
|
||||||
|
|
||||||
|
|
||||||
|
class Twitter
|
||||||
|
/// A simple implementation of a Twitter API client
|
||||||
|
/// (see <http://apiwiki.twitter.com> for more information).
|
||||||
|
///
|
||||||
|
/// Currently, only the update message is supported.
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Twitter();
|
||||||
|
/// Creates the Twitter object, using
|
||||||
|
/// the default Twitter API URI (<http://twitter.com/statuses/>).
|
||||||
|
|
||||||
|
Twitter(const std::string& twitterURI);
|
||||||
|
/// Creates the Twitter object using the given URI.
|
||||||
|
|
||||||
|
~Twitter();
|
||||||
|
/// Destroys the Twitter object.
|
||||||
|
|
||||||
|
void login(const std::string& username, const std::string& password);
|
||||||
|
/// Specifies the username and password used in all API calls that
|
||||||
|
/// require authentication.
|
||||||
|
|
||||||
|
Poco::Int64 update(const std::string& status);
|
||||||
|
/// Updates the user's status.
|
||||||
|
///
|
||||||
|
/// Returns the ID of the newly created status.
|
||||||
|
|
||||||
|
Poco::AutoPtr<Poco::XML::Document> invoke(const std::string& httpMethod, const std::string& twitterMethod, Poco::Net::HTMLForm& params);
|
||||||
|
/// Invokes the given method of the Twitter API, using the parameters
|
||||||
|
/// given in the Poco::Net::HTMLForm object. httpMethod must be GET or POST,
|
||||||
|
/// according to the Twitter API documentation.
|
||||||
|
///
|
||||||
|
/// Returns an XML DOM document containing the server's response if the
|
||||||
|
/// server's HTTP response status code is 200 (OK).
|
||||||
|
/// Otherwise, throws a Poco::ApplicationException.
|
||||||
|
|
||||||
|
static const std::string TWITTER_URI;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Twitter(const Twitter&);
|
||||||
|
Twitter& operator = (const Twitter&);
|
||||||
|
|
||||||
|
std::string _uri;
|
||||||
|
std::string _username;
|
||||||
|
std::string _password;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // Twitter_INCLUDED
|
||||||
@@ -43,6 +43,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SMTPLogger", "SMTPLogger\SM
|
|||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TwitterClient", "TwitterClient\TwitterClient_vs71.vcproj", "{D4483069-8403-4013-822D-100D349ABCA7}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfiguration) = preSolution
|
GlobalSection(SolutionConfiguration) = preSolution
|
||||||
debug_shared = debug_shared
|
debug_shared = debug_shared
|
||||||
@@ -50,8 +54,6 @@ Global
|
|||||||
release_shared = release_shared
|
release_shared = release_shared
|
||||||
release_static = release_static
|
release_static = release_static
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectDependencies) = postSolution
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfiguration) = postSolution
|
GlobalSection(ProjectConfiguration) = postSolution
|
||||||
{1DDAE25B-2263-45B2-8931-C36AD28A0362}.debug_shared.ActiveCfg = debug_shared|Win32
|
{1DDAE25B-2263-45B2-8931-C36AD28A0362}.debug_shared.ActiveCfg = debug_shared|Win32
|
||||||
{1DDAE25B-2263-45B2-8931-C36AD28A0362}.debug_shared.Build.0 = debug_shared|Win32
|
{1DDAE25B-2263-45B2-8931-C36AD28A0362}.debug_shared.Build.0 = debug_shared|Win32
|
||||||
@@ -141,6 +143,14 @@ Global
|
|||||||
{D6C4B3D4-2026-4A33-B4DA-ABE8FF2EE0B8}.release_shared.Build.0 = release_shared|Win32
|
{D6C4B3D4-2026-4A33-B4DA-ABE8FF2EE0B8}.release_shared.Build.0 = release_shared|Win32
|
||||||
{D6C4B3D4-2026-4A33-B4DA-ABE8FF2EE0B8}.release_static.ActiveCfg = release_static|Win32
|
{D6C4B3D4-2026-4A33-B4DA-ABE8FF2EE0B8}.release_static.ActiveCfg = release_static|Win32
|
||||||
{D6C4B3D4-2026-4A33-B4DA-ABE8FF2EE0B8}.release_static.Build.0 = release_static|Win32
|
{D6C4B3D4-2026-4A33-B4DA-ABE8FF2EE0B8}.release_static.Build.0 = release_static|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.debug_shared.ActiveCfg = debug_shared|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.debug_shared.Build.0 = debug_shared|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.debug_static.ActiveCfg = debug_static|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.debug_static.Build.0 = debug_static|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.release_shared.ActiveCfg = release_shared|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.release_shared.Build.0 = release_shared|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.release_static.ActiveCfg = release_static|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.release_static.Build.0 = release_static|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||||
# Visual C++ Express 2005
|
# Visual Studio 2005
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TimeServer", "TimeServer\TimeServer_vs80.vcproj", "{1DDAE25B-2263-45B2-8931-C36AD28A0362}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TimeServer", "TimeServer\TimeServer_vs80.vcproj", "{1DDAE25B-2263-45B2-8931-C36AD28A0362}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HTTPTimeServer", "HTTPTimeServer\HTTPTimeServer_vs80.vcproj", "{7C4285ED-F0BC-4CBA-B1F0-61FCB7FA26C4}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HTTPTimeServer", "HTTPTimeServer\HTTPTimeServer_vs80.vcproj", "{7C4285ED-F0BC-4CBA-B1F0-61FCB7FA26C4}"
|
||||||
@@ -22,6 +22,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HTTPFormServer", "HTTPFormS
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SMTPLogger", "SMTPLogger\SMTPLogger_vs80.vcproj", "{5194085E-A629-4021-B908-BA02101B5B9B}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SMTPLogger", "SMTPLogger\SMTPLogger_vs80.vcproj", "{5194085E-A629-4021-B908-BA02101B5B9B}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TwitterClient", "TwitterClient\TwitterClient_vs80.vcproj", "{D4483069-8403-4013-822D-100D349ABCA7}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
debug_shared|Win32 = debug_shared|Win32
|
debug_shared|Win32 = debug_shared|Win32
|
||||||
@@ -118,6 +120,14 @@ Global
|
|||||||
{5194085E-A629-4021-B908-BA02101B5B9B}.release_shared|Win32.Build.0 = release_shared|Win32
|
{5194085E-A629-4021-B908-BA02101B5B9B}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||||
{5194085E-A629-4021-B908-BA02101B5B9B}.release_static|Win32.ActiveCfg = release_static|Win32
|
{5194085E-A629-4021-B908-BA02101B5B9B}.release_static|Win32.ActiveCfg = release_static|Win32
|
||||||
{5194085E-A629-4021-B908-BA02101B5B9B}.release_static|Win32.Build.0 = release_static|Win32
|
{5194085E-A629-4021-B908-BA02101B5B9B}.release_static|Win32.Build.0 = release_static|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.debug_static|Win32.ActiveCfg = debug_shared|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.debug_static|Win32.Build.0 = debug_shared|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.release_static|Win32.ActiveCfg = release_shared|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.release_static|Win32.Build.0 = release_shared|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HTTPFormServer", "HTTPFormS
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SMTPLogger", "SMTPLogger\SMTPLogger_vs90.vcproj", "{5194085E-A629-4021-B908-BA02101B5B9B}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SMTPLogger", "SMTPLogger\SMTPLogger_vs90.vcproj", "{5194085E-A629-4021-B908-BA02101B5B9B}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TwitterClient", "TwitterClient\TwitterClient_vs90.vcproj", "{D4483069-8403-4013-822D-100D349ABCA7}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
debug_shared|Win32 = debug_shared|Win32
|
debug_shared|Win32 = debug_shared|Win32
|
||||||
@@ -118,6 +120,14 @@ Global
|
|||||||
{5194085E-A629-4021-B908-BA02101B5B9B}.release_shared|Win32.Build.0 = release_shared|Win32
|
{5194085E-A629-4021-B908-BA02101B5B9B}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||||
{5194085E-A629-4021-B908-BA02101B5B9B}.release_static|Win32.ActiveCfg = release_static|Win32
|
{5194085E-A629-4021-B908-BA02101B5B9B}.release_static|Win32.ActiveCfg = release_static|Win32
|
||||||
{5194085E-A629-4021-B908-BA02101B5B9B}.release_static|Win32.Build.0 = release_static|Win32
|
{5194085E-A629-4021-B908-BA02101B5B9B}.release_static|Win32.Build.0 = release_static|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.debug_static|Win32.ActiveCfg = debug_shared|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.debug_static|Win32.Build.0 = debug_shared|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.release_static|Win32.ActiveCfg = release_shared|Win32
|
||||||
|
{D4483069-8403-4013-822D-100D349ABCA7}.release_static|Win32.Build.0 = release_shared|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
Reference in New Issue
Block a user