Facebook sharing not working normally - facebook

After facebook sharing I need return to my website. But facebook redirect me to https://www.facebook.com/dialog/return/close#=. Earlier all work good. Can you help me with this problem?
Code:
facebook script:
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
share link:
<a href='https://www.facebook.com/sharer/sharer.php?u=http%3A//www.mysite.com/share/somepost/1>Share on Facebook</a>

Related

Image not loading from css file

I have managed to display html in a UIWebView, but my problem is that the images are not displaying in my HTML, although my images, css, and javascript are all located in the same project folder.
Here is the my HTML:
<html>
<head>
<meta name = "viewport" content = "initial-scale = 1.0, user-scalable = no, width = 320"/>
<link rel="stylesheet" type="text/css" href="site.css">
<script src="site.js" type="text/javascript" />
</head>
<body style="margin:0;padding:0;">
<div class="player"></div>
<div class="controller">
<div class="search"></div>
</div>
</body>
</html>
Here is my CSS:
body{
padding:0;
margin:0;
}
div.player{
width:320px;
height:180px;
}
div.controller{
float:left;
width:320px;
}
div.search{
float:left;
height:40px;
width:320px;
background-image:url('search.jpg');
}
And, finally, my Objective-C:
-(void)viewDidLoad {
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:#"index" ofType:#"html"];
NSString *htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
[navigatorWindow loadHTMLString:htmlString baseURL:baseURL];
NSLog(#"%#",htmlString);
[super viewDidLoad];
}
Any idea what's going on here?
Make sure that search.jpg is adding to the Xcode Project. I believe that's the problem, because it is a local html file and not hosted on a server. Hope this helps.
background-image:url('search.jpg'); you have to give the full path of image here

while parse the HTML using NSXMLParser, not full data in iPhone

while parse the xml, not full data is getting after some word line end with read more
below three codes are in a single html page i spited that for better understanding.
i am parsing this in to my iPhone app using NSXMLParser.
problem is its parsing till <Style> below then it stops parsing from the text after that and completely ignores the data below the text!!!
<head>
<title>North Mobile County Middle School: Latest News > "1st Annual NMCK-8 Christmas Music Program"</title>
<META HTTP-EQUIV="X-UA-COMPATIBLE" CONTENT="IE=EmulateIE9">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="imagetoolbar" content="no">
<script type="text/javascript" src="JavaScripts.js"></script>
<script type="text/javascript" src="JavaScripts/NiceTitles.js"></script>
<style type="text/css">
i am splitting the code for better understanding
!--
body {
margin:0; padding:0;
background: #fff;}
body, td {
font: normal 13px "Trebuchet MS", Arial, Helvetica, sans-serif;
color:#333;}
/***********************************************/
/* Links
/***********************************************/
a:link, a:visited {
color: #CD0000;
text-decoration: none;}
a:hover, a:active {
color: #06f;
text-decoration: underline;}
img {border: 0;}
i am splitting the code for better understanding
#MainPageArea {padding: 0 15px 15px 15px}
</style>
<link href="http://images.pcmac.org/SiSFiles/Schools/AL/MobileCounty/NorthMobileMiddle/styles.css" rel="stylesheet" type="text/css">
<!--[if lt IE 7]>
<link href="Common/CommonIncludes/Template11/IEStyles.css" rel="stylesheet" type="text/css">
<![endif]-->
<link rel="Shortcut Icon" type="image/ico" href="http://images.pcmac.org/SiSFiles/Schools/AL/MobileCounty/NorthMobileMiddle/images/favicon.ico" />
</head>
<body class="DefaultPage">
<table align="center" cellpadding="0" cellspacing="0" width="986" border="0" id="PageWrapper">
<tr>
<td valign="top">
<div id="Header">
i am using code as below:
-(id) loadHtmlByURL:(NSString *)urlString
{
NSURL *url = [NSURL URLWithString:urlString];
NSData *nsData = [[NSData alloc] initWithContentsOfURL:url];
elementArray = [[NSMutableArray alloc] init];
parser = [[NSXMLParser alloc] initWithData:nsData];
parser.delegate = self;
[parser parse];
currentHTMLElement = [HtmlElement alloc];
return self;
}
- (void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementname namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
NSLog(#"%#",elementname);
currentHTMLElement = [[HtmlElement alloc] autorelease];
}
- (void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementname namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
NSLog(#"%#",elementname);
if ([elementname isEqualToString:#"head"])
{
currentHTMLElement.tag = elementname;
currentHTMLElement.value = currentNodeContent;
[elementArray addObject:currentHTMLElement];
currentHTMLElement = nil;
currentNodeContent = nil;
// NSLog(#"x%#",elementArray);
}
can i know were i was struck
You should only use the NSXMLParser class to parse stuff that’s actually XML. HTML is not, except if it’s XHTML, which your source is not: The meta tags aren’t closed and your style tag starts with a comment that is never closed (which, I guess, is the reason why the parser never reads past that); also, the title’s text node contents should only contain escaped versions of > and " (the escape sequences being > and ").
If you’re in control of the HTML, try changing it to be XML- (and, thus, XHTML-) compliant. If you can’t change the HTML, try tag soup parsing, for example with hpple.
Here is the tutorial for Parsing HTML page
http://www.raywenderlich.com/14172/how-to-parse-html-on-ios

Load the SDK Asynchronously without server web

I need to know if it's possible load the javascript SDK without a server web:
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script');
js.id = id;
js.async = true;
js.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
ref.parentNode.insertBefore(js, ref);
console.log("1");
}(document));
My problem is that the line js.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; doesn't load correctly because calls the url:
GET file://connect.facebook.net/en_US/all.js
and the response is Not Found.
If anyone know what can i do for load asynchronously the javascript SDK for Facebook without server web i would appreciate it.
Thx!!
Copy/Save the all.js file in your app directory and change the line:
js.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
to
js.src = 'your_app/js/all.js';
but have in mind that this is not a good method for production purposes, because you will not be able to follow any updates made from Facebook.

Extract all the <script> tags from an HTML file and store that in an NSArray- Objective C

I am trying to get the src of all the script tags and i want to store that an in an array. I am really stuck with these any help would really be appreciated.
<script type="text/javascript" src='//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js'></script>
<script type="text/javascript" src='static/tabthemes/js/json2.js'></script>
<script type="text/javascript" src='static/tabthemes/js/underscore.min.js'></script>
<script type="text/javascript" src='static/tabthemes/js/backbone.min.js'></script>
<script type="text/javascript" src='static/tabthemes/js/mustache.js'></script>
<script type="text/javascript" src='static/tabthemes/js/jquery.wipetouch.js'></script>
<script type="text/javascript" src='/static/tabthemes/js/spin.js'></script>
Somebody please help me with this !! :(
You can try with NSRegularExpression, e.g.:
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:#" src='([^.]*)'" options:NSRegularExpressionCaseInsensitive error:&error];
then check NSRegularExpression reference for ways to match the actual data. In your case, the method
- (NSArray *)matchesInString:(NSString *)string options:(NSMatchingOptions)options range:(NSRange)range
should do exactly what you are after.
You can also try the dirty way : splitting the string at some markers you spotted (here I use the src=' and then the last quote). It works with the string you gave, but it is not very safe. You should prefer the regex method given before.
Here is the piece of code you could try :
NSMutableArray *retArray = [[NSMutableArray alloc] init];
NSArray *components = [string componentsSeparatedByString:#"src='"];
for(int i = 1; i < components.count; i++)
{
NSArray *innerComponents = [[components objectAtIndex:i] componentsSeparatedByString:#"'"];
[retArray addObject:[innerComponents objectAtIndex:0]];
}

How to load Google Maps Faster in iPhone

in my iPhone application I'm loading the driving directions to a WebView from a bundled html page (because i can't find a way to load it directly to the MapKit), but it taking too much time to load, is there any better way to do so? Like in the iPhone default map application
code :
NSString *filePathString = [[NSBundle mainBundle] pathForResource:#"drive_index" ofType:#"html"];
NSMutableString *html = [[NSMutableString alloc] initWithContentsOfFile: filePathString];
[html replaceOccurrencesOfString: #"varLocation1" withString:loc1
options: NSLiteralSearch range: NSMakeRange(0, [html length])];
[html replaceOccurrencesOfString: #"varLocation2" withString:loc2
options: NSLiteralSearch range: NSMakeRange(0, [html length])];
NSURL *aURL = [NSURL fileURLWithPath:filePathString];
[webView loadHTMLString:html baseURL:aURL];
and the html page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example: Simple Map</title>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA"
type="text/javascript"></script>
<script type="text/javascript">
var directionsPanel;
var directions;
var location1="varLocation1";
var location2="varLocation2";
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(location1), 13);
directionsPanel = document.getElementById("route");
directions = new GDirections(map, directionsPanel);
directions.load('from: ' + location1 +' to: '+ location2 );
}
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width:divice-width ; height:350px ; float:top; border: 1px solid black;"></div>
<div id="route" style="width:divice-width; border; 1px solid black;"></div>
</body>
</html>
Have a look at this answer:
Showing Driving Directions in MapKit
It says a way to use the Map Kit (which doesn't include driving directions) and overlay lines directly on top. Here's the site they reference:
http://spitzkoff.com/craig/?p=65
You should definitely see if you can switch to V3 of the Google Maps API. It was specifically designed to load quickly on mobile browsers. The only problem (and it's a big one) is that it doesn't support directions yet.