脸书打开图动态地图布局



我可以成功地将路线发布到facebook Open Graph,路线将显示在他们的地图中。但是,这仅在我像这样对 php 中的坐标进行硬编码时才有效:

<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"> -->

通过在 php 中添加坐标来修复。不需要大的网址。

最新更新