0
我可以成功地發佈路線到Facebook Open Graph,路線將顯示在他們的地圖中。然而,這隻適用於當我硬編碼像我這樣的座標:Facebook Open Graph動態地圖佈局
<meta property="vaarapp:route:longitude" content="4.948997">
<meta property="vaarapp:route:altitude" content="0.01">
<meta property="vaarapp:route:latitude" content="52.24525">
<meta property="vaarapp:route:longitude" content="4.948997">
<meta property="vaarapp:route:altitude" content="0.01">
但我想從我的iphone動態添加這些座標。我已經有一個座標數組,但不知道如何發送這個作爲一個變量的PHP腳本。有人可以幫我嗎?
這是怎麼了,我從我的iPhone將信息發送到PHP腳本,這將最終發佈的行動在我的Facebook應用程序:
NSMutableString *format = [self createFacebookFormat];
NSString *attributes =
@"fb:app_id=421596134540169&og:type=%@&"
@"og:title=%@&og:description=%%22Lorem ipsum test description%%22&"
@"og:image=%@&"
@"vaarapp:distance=%d&"
@"vaarapp:time=%d&"
@"vaarapp:location:latitude=%f&"
@"vaarapp:location:longitude=%f&";
[format appendString:attributes];
// create an FBGraphObject object, but we can treat it as
// an FBRoute with typed properties, etc. See <FacebookSDK/FBGraphObject.h>
// for more details.
id<FBLocation> result = (id<FBLocation>)[FBGraphObject graphObject];
// Give it a URL that will echo back the name of the meal as its title,
// description, and body.
result.url = [NSString stringWithFormat:format, ogObject, title, catagory, 10, 4, coordinate.latitude, coordinate.longitude];
PHP腳本是這樣的:
function curPageURL() {
$pageURL = 'http://';
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
?>
<html>
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# vaarapp: http://ogp.me/ns/fb/vaarapp#">
<meta property="fb:app_id" content="<?php echo strip_tags($_REQUEST['fb:app_id']);?>">
<meta property="og:url" content="<?php echo strip_tags(curPageURL());?>">
<meta property="og:type" content="<?php echo strip_tags($_REQUEST['og:type']);?>">
<meta property="og:title" content="<?php echo strip_tags($_REQUEST['og:title']);?>">
<meta property="og:image" content="<?php echo strip_tags($_REQUEST['og:image']);?>">
<meta property="og:description" content="<?php echo strip_tags($_REQUEST['app:description']);?>">
<meta property="app:location:latitude" content="<?php echo strip_tags($_REQUEST['app:location:latitude']);?>">
<meta property="app:location:longitude" content="<?php echo strip_tags($_REQUEST['app:location:longitude']);?>">
<meta property="app:distance" content="<?php echo strip_tags($_REQUEST['app:distance']);?>">
<meta property="app:time" content="<?php echo strip_tags($_REQUEST['app:time']);?>">
<!-- <meta property="app:route:latitude" content="52.24525">
<meta property="app:route:longitude" content="4.948997">
<meta property="app:route:altitude" content="0.01">
<meta property="app:route:latitude" content="52.24525">
<meta property="app:route:longitude" content="4.948997">
<meta property="app:route:altitude" content="0.01">
<meta property="app:route:latitude" content="52.239785">
<meta property="app:route:longitude" content="4.920502">
<meta property="app:route:altitude" content="0.01">
<meta property="app:route:latitude" content="52.233162">
<meta property="app:route:longitude" content="4.978008">
<meta property="app:route:altitude" content="0.01"> -->
我實際上設法使用數組值來回顯行,但是我的GET URL會將waaaaay變大。如此之大以至於大型路線出現錯誤。 我可以使用POST insted GET嗎。如果有的話,有人可以給我一個例子嗎? –