dpwo36915 2015-03-05 19:48
浏览 53

在json url中调用php函数?

this is probably a VERY stupid question but I'm a bit new into this so please help me out. I have written a mini code using instagram API that loads photos from a specific location, using the location id. Now what I want to achieve is that use this for a wordpress website i'm building that lists some hotels and restaurants. I've defined the location id as a custom field, so I need to use the following code to call it:

<?php echo get_post_meta($post->ID, 'Instagram', true); ?>

And my url to call the photos is the following:

<?php $result = fetchData("https://api.instagram.com/v1/locations/LOCATION-ID-HERE/media/recent/?access_token={$accessToken}&count=6");?>

The above code works if i insert a location id manually. What I want to achieve is insert the above code into the "location-id-here" part. I guess this is quite simple but I'm kind of confused as both are php functions.

Any help would be greatly appreciated!

  • 写回答

1条回答 默认 最新

  • drhe80011 2015-03-05 19:53
    关注

    The parameter you're putting in fetchData() is just a string, so you can concatenate output from another function into that string with the . operator:

    <?php 
    $result = fetchData("https://api.instagram.com/v1/locations/" . get_post_meta($post->ID, 'Instagram', true) . "/media/recent/?access_token={$accessToken}&count=6");
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作