Helpers\SimpleCurl
Helpers\SimpleCurl
The SimpleCurl class is there to curl data from RESTful services. A lot of companies use it nowadays for example twitter, google and facebook.
There are four methods available these are get, post and put.
You will need to declare the SimpleCurl helper first to use these examples below. You can do it by adding a use statement at the top of the controller.
use Helpers\SimpleCurl as Curl
How to do a get request
This example will show you how to a get request to get the current bitcoin prices from coinbase
// Get the spot price of a bitcoin it returns a json object.
$spotrate = Curl::get('https://coinbase.com/api/v1/prices/spot_rate');
$data['spotrate'] = json_decode($spotrate);
The get request returned the data as json data we encoded it and passed it to our view.
Inside your view you could simply do
echo $data['spotrate']->amount;
echo $data['spotrate']->currency;
This should print out the currency and rate.
How to do a post request
This example will show you how to post a gist to github gists.
// Post a gist to github
$content = "Hello World!";
$response = Curl::post('https://api.github.com/gists', json_encode(array(
'description' => 'PHP cURL Post Test',
'public' => 'true',
'files' => array(
'Test.php' => array(
'content' => $content,
),
),
)));
The response will be details of the file and the url where it's located.
How to do a put request
This example will show you how to do a put request to httpbin a test service for curl.
$response = Curl::put('http://httpbin.org/put', array(
'id' => 1,
'first_name' => 'Nova',
'last_name' => 'Framework'
));
Helpers\SimpleCurl的更多相关文章
- Config
Config Config App Auth Cache Database Languages Mail Modules Routing Session Config Settings for the ...
- ASP.NET Core 中文文档 第四章 MVC(3.6.1 )Tag Helpers 介绍
原文:Introduction to Tag Helpers 作者:Rick Anderson 翻译:刘浩杨 校对:高嵩(Jack) 什么是 Tag Helpers? Tag Helpers 提供了什 ...
- ASP.NET Core 中文文档 第四章 MVC(3.6.2 )自定义标签辅助类(Tag Helpers)
原文:Authoring Tag Helpers 作者:Rick Anderson 翻译:张海龙(jiechen) 校对:许登洋(Seay) 示例代码查看与下载 从 Tag Helper 讲起 本篇教 ...
- [asp.net core]定义Tag Helpers
原文地址 https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/authoring Getting started wi ...
- [asp.net core] Tag Helpers 简介(转)
原文地址 https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/intro What are Tag Helpers? ...
- Handlebars块级Helpers
1.Handlebars简单介绍: Handlebars是JavaScript一个语义模板库,通过对view和data的分离来快速构建Web模板.它采用"Logic-less templat ...
- 在 ASP.NET MVC 中使用 HTML Helpers 的那些事
在 ASP.NET MVC 中使用 HTML Helpers 方法,可以返回得到标准的 HTML 标签,就像 <input>.<button> 或者 <img> 等 ...
- 理解ASP.NET MVC中的HTML Helpers
01 内联Html Helpers @helper listItems(string[] items) { <ol> @foreach (var item in items) { < ...
- CKEditor Html Helpers for ASP.NET MVC3 Razor/WebForms Views
一.原生方法: 在 razor 中 使用Fckeditor 编辑内容,需要引入js <script src="@Url.Content("~/fckeditor/fckedi ...
随机推荐
- python学习之subprocess模块
subprocess.Popen 这个模块主要就提供一个类Popen: class subprocess.Popen( args, bufsize=0, executable=None, stdin= ...
- matlab特征值分解和奇异值分解
特征值分解 函数 eig 格式 d = eig(A) %求矩阵A的特征值d,以向量形式存放d. d = eig(A,B) %A.B为方阵,求广义特征值d,以向量形式存放d. ...
- Tkinter教程之Pack篇
本文转载自:http://blog.csdn.net/jcodeer/article/details/1813077 '''Tkinter教程之Pack篇'''#Pack为一布局管理器,可将它视为一个 ...
- 在阿里云linux下使用SVN访问VisualSVN出错:SSL handshake failed: SSL error: Key usage violation in certificate has been detected
Subversion clients receive the following error message when attempting to connect to VisualSVN Serve ...
- SQL Server 2000的并发连接数是多少
开始->管理工具->性能(或者是运行里面输入 mmc)然后通过 添加计数器添加 SQL 的常用统计(MSSQL General Statistics) 然后在下面列出的项目里面选择 用户连 ...
- 【移动开发】安卓Lab2(01)
本次Lab需要用到Google Map的API,分享学习一下Google Map的知识 需求: 界面: 1. 主界面(map界面): 提供了指定的学校校园地图图片,不能用Google的API生成图片 ...
- 用java获取歌曲文件的专辑封面元信息
几个个软件: 1, Jaudioatgger: 链接 2, mp3agic 链接 3, Java mp3 id3 tag library (推荐用上面两个) 其它: android-midi-lib
- 转】Maven学习总结(三)——使用Maven构建项目
原博文出自于: http://www.cnblogs.com/xdp-gacl/p/4240930.html 感谢! maven作为一个高度自动化构建工具,本身提供了构建项目的功能,下面就来体验一下使 ...
- Oracle 查看表空间大小及其扩展
在ORACLE数据库中,所有数据从逻辑结构上看都是存放在表空间当中,当然表空间下还有段.区.块等逻辑结构.从物理结构上看是放在数据文件中.一个表空间可由多个数据文件组成.系统中默认创建的几个表空间:S ...
- BestCoder Round #67 (div.2) N bulbs(hdu 5600)
N bulbs Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Su ...