I want to implement yelp API in my new project.Downloaded their library and sample code.But this library is very old, uploaded 3 year back.I don't know how to include it in symfony2.3.Can anyone tell me that how to include this type of files in symfony2.3 projects.
1条回答 默认 最新
- dsfliu1129 2014-01-21 12:19关注
I think you can define it as services like this:
First of all include the Api inside your bundle, for example in:
Acme/YourBundle/Yelp/
But you will have to seperate the classes in individual files:
Acme/YourBundle/Yelp/OAuthToken.php Acme/YourBundle/Yelp/OAuthConsumer.php Acme/YourBundle/Yelp/OAuthSignatureMethod_HMAC_SHA1.php Acme/YourBundle/Yelp/OAuthRequest.php
And add a namespace to each:
namespace Acme\YourBundle\Yelp; class OAuthToken { ...
Then define the keys in your
app/config/parameter.yml
:parameters: yelp_token: "..." yelp_token_secret: "..." consumer_key: "..." consumer_secret: "..."
Now the services in
app/config/config.yml
services: yelp_token: class: Acme\YourBundle\Yelp\OAuthToken arguments: [%yelp_token%, %yelp_token_secret%] yelp_consumer: class: Acme\YourBundle\Yelp\OAuthConsumer arguments: [%consumer_key%, %consumer_secret%] yelp_signature_method: class: Acme\YourBundle\Yelp\OAuthSignatureMethod_HMAC_SHA1 yelp_oauthrequest: class: Acme\YourBundle\Yelp\OAuthRequest
And in your controllers you can access the classes like this:
$yelp_token = $this->container->get('yelp_token');
I don't think this is a copy/paste solution but it might guide you in the right direction.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
- ¥50 opencv4nodejs 如何安装
- ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
- ¥15 nginx反向代理获取ip,java获取真实ip
- ¥15 eda:门禁系统设计
- ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
- ¥15 376.1电表主站通信协议下发指令全被否认问题
- ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
- ¥15 复杂网络,变滞后传递熵,FDA
- ¥20 csv格式数据集预处理及模型选择