kindly help me resolve the below error i.e. http://charag.com/fb/cg7/
- HTTP request error
- Security error accessing url
Hi, i am calling httpservices to get tweet and image via twitter api i.e.
http://api.twitter.com/1/users/show....n_name=charagh
the flash builder application works fine but once i close it, it generates errors, i put crossdomain.xml but still it doesnt work
error which am getting i.e.
Actionscript Code:
Fault 0 (Error):
[Channel.Security.Error]
FAULT MESSAGE: faultCode:Channel.Security.Error faultString:'Security error accessing url' faultDetail:'Destination: DefaultHTTP'
FAULT DETAILS: Destination: DefaultHTTP
FAULT STRING: Security error accessing url
FAULT ON TARGET:
(::HTTPOperation)#0
argumentNames = (null)
arguments = (Object)#1
concurrency = "multiple"
contentType = "application/x-www-form-urlencoded"
headers = (Object)#2
lastResult = (null)
makeObjectsBindable = true
method = "GET"
name = (null)
operationManager = (null)
properties = (null)
request = (Object)#3
requestTimeout = -1
resultElementType = (null)
resultFormat = "e4x"
resultType = (null)
rootURL = "http://charag.com/fb/cg7/index.swf"
serializationFilter = (null)
service = (null)
showBusyCursor = false
url = "http://api.twitter.com/1/users/show.xml?screen_name=charagh"
useProxy = false
xmlDecode = (null)
xmlEncode = (null)
offline error on localhost i.e.
Actionscript Code:
Fault 0 (Error):
[Server.Error.Request]
FAULT MESSAGE: faultCode:Server.Error.Request faultString:'HTTP request error' faultDetail:'Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost:37813/1/users/show.xml?screen_name=charagh?hostport=api.twitter.com&https=N&id=7B4A8B9C-E3D7-88FD-9F96-350FE2FAE8EB"]. URL: [url]http://api.twitter.com/1/users/show.xml?screen_name=charagh[/url]'
FAULT DETAILS: Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost:37813/1/users/show.xml?screen_name=charagh?hostport=api.twitter.com&https=N&id=7B4A8B9C-E3D7-88FD-9F96-350FE2FAE8EB"]. URL: [url]http://api.twitter.com/1/users/show.xml?screen_name=charagh[/url]
FAULT STRING: HTTP request error
FAULT ON TARGET:
(HTTPService.as$35::HTTPOperation)#0
argumentNames = (null)
arguments = (Object)#1
concurrency = "multiple"
contentType = "application/x-www-form-urlencoded"
headers = (Object)#2
lastResult = (null)
makeObjectsBindable = true
method = "GET"
name = (null)
operationManager = (null)
properties = (null)
request = (Object)#3
requestTimeout = -1
resultElementType = (null)
resultFormat = "e4x"
resultType = (null)
rootURL = "http://localhost/card/bin-debug/index.swf"
serializationFilter = (null)
service = (null)
showBusyCursor = false
url = "http://api.twitter.com/1/users/show.xml?screen_name=charagh"
useProxy = false
xmlDecode = (null)
xmlEncode = (null)
my mxml code i.e.
Actionscript Code:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" creationComplete="init(event)"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.collections.XMLListCollection;
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
import mx.utils.ObjectUtil;
private var twitterText:String;
[Bindable]
private var twitterCount:String;
[Bindable]
private var tweetdate:String;
[Bindable]
private var twitterImage:String;
[Bindable]
private var tweetArray:ArrayCollection;
[Bindable]
private var datalist:XMLListCollection;
private var a:Alert;
protected function image1_clickHandler(event:MouseEvent):void
{
navigateToURL(new URLRequest("https://twitter.com/charagh"),"_blank");
}
protected function init(event:FlexEvent):void
{
Security.allowDomain("charag.com");
Security.loadPolicyFile("crossdomain.xml");
twitterText = "charagh";
tweetUser.url="http://api.twitter.com/1/users/show.xml?screen_name="+twitterText;
tweetUser.send();
tweetUser.addEventListener(ResultEvent.RESULT,tweetUser_resultHandler);
}
protected function tweetUser_resultHandler(event:ResultEvent):void
{
Alert.buttonWidth = 120;
var x:XML = event.result as XML;
var childName:String = "status";
//Alert.show(x.child(childName).text);
yourmessage = x.profile_image_url;
a = Alert.show( yourmessage,title);
a.mx_internal::alertForm.mx_internal::textField.selectable = false;
twitterImage = x.profile_image_url;
twitterText = x.status.text;
tweetdate = x.status.created_at;
twitterCount = twitterText+" "+tweetdate;
}
protected function tweetUser_faultHandler(event:FaultEvent):void
{
//http://marxsoftware.blogspot.com/2007/11/placing-flex-errorfault-information-on.html
const faultEventTarget:String = ObjectUtil.toString(event.currentTarget);
const faultErrorId:int = event.fault.errorID;
const faultErrorCode:String = event.fault.faultCode;
const faultErrorDetail:String = event.fault.faultDetail;
const faultString:String = event.fault.faultString;
const faultMessage:String = event.fault.message;
const faultName:String = event.fault.name;
const faultErrorString:String =
"Fault " + faultErrorId + " (" + faultName + "):\n"
+ "[" + faultErrorCode + "]\n\n"
+ "FAULT MESSAGE: " + faultMessage + "\n\n"
+ "FAULT DETAILS: " + faultErrorDetail + "\n\n"
+ "FAULT STRING: " + faultString + "\n\n"
+ "FAULT ON TARGET:\n" + faultEventTarget;
const faultVerboseErrorString:String =
faultErrorString + "\n\n" + "FAULT ON TARGET:\n" + faultEventTarget;
trace(faultVerboseErrorString);
Alert.show(faultErrorString, "Intentional Fault Occurred");
<font color="red">flash.system.System.setClipboard(faultVerboseErrorString);</font>
// var faultstring:String = event.fault.faultString;
// a = Alert.show(faultstring);
//Alert.show(event.fault.faultDetail);
}
]]>
</fx:Script>
<fx:Declarations>
<fx:String id="title">Error Message</fx:String>
<fx:String id="yourmessage"></fx:String>
<s:HTTPService id="tweetUser" useProxy="false" method="GET" resultFormat="e4x">
</s:HTTPService>
</fx:Declarations>
<s:Image buttonMode="true" width="48" height="48" x="141" y="169" click="image1_clickHandler(event)" source="{twitterImage}"/>
<s:Label id="twitterNumber" x="192" y="169" width="488" height="47" color="#000000"
fontFamily="Georgia" fontSize="12" fontWeight="normal" text="{twitterCount}"
textAlign="center" verticalAlign="middle"/>
</s:Application>
cross domain.xml
Actionscript Code:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy xsi:noNamespaceSchemaLocation="http://www.adobe.com/xml/schemas/PolicyFile.xsd">
<allow-access-from domain="charag.com"/>
<allow-access-from domain="*.charag.com"/>
<allow-access-from domain="a1.twimg.com"/>
<allow-access-from domain="*.twitter.com"/>
<allow-access-from domain="twitter.com"/>
<allow-access-from domain="api.twitter.com"/>
<allow-access-from domain="search.twitter.com"/>
<allow-access-from domain="static.twitter.com"/>
<site-control permitted-cross-domain-policies="master-only"/>
<allow-access-from domain="a1.twimg.com"/>
<allow-http-request-headers-from domain="*.twitter.com" headers="*" secure="true"/>
</cross-domain-policy>